Skip to content

FEATURE: refacto to load plugins dynamically #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ext-json": "*",
"nikic/php-parser": "^4.10",
"symfony/config": "^5.2",
"php-etl/configurator-contracts": "^0.3.0",
"php-etl/configurator-contracts": "^0.4.0",
"php-etl/packaging-contracts": "^0.1.0",
"symfony/expression-language": "^5.2",
"php-etl/satellite-toolbox": "^0.1.0"
Expand All @@ -41,7 +41,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.3.x-dev"
"dev-master": "0.4.x-dev"
},
"satellite": {
"class": "Kiboko\\Plugin\\CSV\\Service"
Expand Down
11 changes: 8 additions & 3 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace Kiboko\Plugin\CSV;

use Kiboko\Plugin\Log;
use Kiboko\Component\Satellite\NamedConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

final class Configuration implements ConfigurationInterface
final class Configuration implements ConfigurationInterface, NamedConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$extractor = new Configuration\Extractor();
$loader = new Configuration\Loader();

$builder = new TreeBuilder('csv');
$builder = new TreeBuilder($this->getName());
$builder->getRootNode()
->validate()
->ifTrue(function (array $value) {
Expand All @@ -35,4 +35,9 @@ public function getConfigTreeBuilder(): TreeBuilder

return $builder;
}

public function getName(): string
{
return 'csv';
}
}
22 changes: 21 additions & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Kiboko\Plugin\CSV;

use Kiboko\Contract\Configurator\ConfiguratorExtractorInterface;
use Kiboko\Contract\Configurator\ConfiguratorLoaderInterface;
use Kiboko\Contract\Configurator\ConfiguratorPackagesInterface;
use Kiboko\Contract\Configurator\RepositoryInterface;
use Kiboko\Contract\Configurator\InvalidConfigurationException;
use Kiboko\Contract\Configurator\FactoryInterface;
Expand All @@ -10,7 +13,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

final class Service implements FactoryInterface
final class Service implements FactoryInterface, ConfiguratorLoaderInterface, ConfiguratorExtractorInterface, ConfiguratorPackagesInterface
{
private Processor $processor;
private ConfigurationInterface $configuration;
Expand Down Expand Up @@ -75,4 +78,21 @@ public function compile(array $config): RepositoryInterface
throw new InvalidConfigurationException($exception->getMessage(), 0, $exception);
}
}

public function getExtractorKey(): string
{
return 'extractor';
}

public function getLoaderKeys(): array
{
return ['loader'];
}

public function getPackages(): array
{
return [
'php-etl/csv-flow:^0.2.0',
];
}
}
1 change: 0 additions & 1 deletion tests/functional/Builder/ExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace functional\Kiboko\Plugin\CSV\Builder;

use Kiboko\Plugin\CSV\Builder;
use Kiboko\Plugin\Log;
use PhpParser\Node;

final class ExtractorTest extends BuilderTestCase
Expand Down
1 change: 0 additions & 1 deletion tests/functional/Builder/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace functional\Kiboko\Plugin\CSV\Builder;

use Kiboko\Plugin\CSV\Builder;
use Kiboko\Plugin\Log;
use PhpParser\Node;

final class LoaderTest extends BuilderTestCase
Expand Down