42648b4ee853f2cab7c1e6b7de21a85ceed496d0
[yaffs-website] / vendor / drupal / console / src / Bootstrap / FindCommandsCompilerPass.php
1 <?php
2
3 namespace Drupal\Console\Bootstrap;
4
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8 /**
9  * FindCommandsCompilerPass
10  */
11 class FindCommandsCompilerPass implements CompilerPassInterface
12 {
13     /**
14      * @var string
15      */
16     protected $serviceTag;
17
18     /**
19      * FindCommandsCompilerPass constructor.
20      *
21      * @param $serviceTag
22      */
23     public function __construct($serviceTag)
24     {
25         $this->serviceTag = $serviceTag;
26     }
27
28     /**
29      * @inheritdoc
30      */
31     public function process(ContainerBuilder $container)
32     {
33         $taggedServices = $container->findTaggedServiceIds(
34             $this->serviceTag
35         );
36
37         $commands = [];
38         foreach ($taggedServices as $id => $tags) {
39             $commands[] = $id;
40         }
41
42         $container->setParameter('drupal.commands', $commands);
43     }
44 }