-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[All] DependencyInjection new ContainerBuilderIntegrationInterface
- Loading branch information
Showing
41 changed files
with
319 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ages/aws-tool-kit/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Draw\Component\AwsToolKit\DependencyInjection\Compiler; | ||
|
||
use Draw\Component\AwsToolKit\EventListener\NewestInstanceRoleCheckListener; | ||
use Draw\Component\DependencyInjection\Container\DefinitionFinder; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; | ||
|
||
class AddNewestInstanceRoleCommandOptionPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
try { | ||
$container->findDefinition(NewestInstanceRoleCheckListener::class); | ||
} catch (ServiceNotFoundException) { | ||
return; | ||
} | ||
|
||
foreach (DefinitionFinder::findConsoleCommandDefinitions($container) as $definition) { | ||
$definition | ||
->addMethodCall( | ||
'addOption', | ||
[ | ||
NewestInstanceRoleCheckListener::OPTION_AWS_NEWEST_INSTANCE_ROLE, | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'The instance role the server must be the newest of to run the command.', | ||
] | ||
); | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...westInstanceRoleCommandOptionPassTest.php → ...westInstanceRoleCommandOptionPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...mmandExecutionOptionsCompilerPassTest.php → ...mmandExecutionOptionsCompilerPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/cron-job/DependencyInjection/Compiler/AddPostCronJobExecutionOptionPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Draw\Component\CronJob\DependencyInjection\Compiler; | ||
|
||
use Draw\Component\CronJob\EventListener\PostExecutionQueueCronJobListener; | ||
use Draw\Component\DependencyInjection\Container\DefinitionFinder; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; | ||
|
||
class AddPostCronJobExecutionOptionPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
try { | ||
$container->findDefinition(PostExecutionQueueCronJobListener::class); | ||
} catch (ServiceNotFoundException) { | ||
return; | ||
} | ||
|
||
foreach (DefinitionFinder::findConsoleCommandDefinitions($container) as $definition) { | ||
$definition | ||
->addMethodCall( | ||
'addOption', | ||
[ | ||
PostExecutionQueueCronJobListener::OPTION_POST_EXECUTION_QUEUE_CRON_JOB, | ||
null, | ||
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, | ||
'Queue does cron job by name after execution of the command.', | ||
] | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/dependency-injection/Container/DefinitionFinder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Draw\Component\DependencyInjection\Container; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class DefinitionFinder | ||
{ | ||
/** | ||
* @return iterable<Definition> | ||
*/ | ||
public static function findConsoleCommandDefinitions(ContainerBuilder $container, bool $ignoreAbstract = true): iterable | ||
{ | ||
foreach (array_keys($container->findTaggedServiceIds('console.command')) as $serviceId) { | ||
$definition = $container->getDefinition($serviceId); | ||
if ($ignoreAbstract && $definition->isAbstract()) { | ||
continue; | ||
} | ||
|
||
yield $definition; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../Compiler/TagIfExpressionCompilerPass.php → .../Compiler/TagIfExpressionCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/dependency-injection/DependencyInjection/DependencyInjectionIntegration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Draw\Component\DependencyInjection\DependencyInjection; | ||
|
||
use Draw\Component\DependencyInjection\DependencyInjection\Compiler\TagIfExpressionCompilerPass; | ||
use Draw\Component\DependencyInjection\Integration\ContainerBuilderIntegrationInterface; | ||
use Draw\Component\DependencyInjection\Integration\IntegrationInterface; | ||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; | ||
|
||
class DependencyInjectionIntegration implements IntegrationInterface, ContainerBuilderIntegrationInterface | ||
{ | ||
public function getConfigSectionName(): string | ||
{ | ||
return 'dependency_injection'; | ||
} | ||
|
||
public function buildContainer(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new TagIfExpressionCompilerPass()); | ||
} | ||
|
||
public function load(array $config, PhpFileLoader $loader, ContainerBuilder $container): void | ||
{ | ||
} | ||
|
||
public function addConfiguration(ArrayNodeDefinition $node): void | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/dependency-injection/Integration/ContainerBuilderIntegrationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Draw\Component\DependencyInjection\Integration; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
interface ContainerBuilderIntegrationInterface | ||
{ | ||
public function buildContainer(ContainerBuilder $container): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/Compiler/EntityMigratorCompilerPass.php → ...n/Compiler/EntityMigratorCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...work-extra-bundle/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.