Version 1
[yaffs-website] / vendor / drupal / console / src / Bootstrap / DrupalServiceModifier.php
1 <?php
2
3 namespace Drupal\Console\Bootstrap;
4
5 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
6 use Drupal\Core\DependencyInjection\ContainerBuilder;
7
8 class DrupalServiceModifier implements ServiceModifierInterface
9 {
10     /**
11      * @var string
12      */
13     protected $root;
14
15     /**
16      * @var string
17      */
18     protected $appRoot;
19
20     /**
21      * @var string
22      */
23     protected $commandTag;
24
25     /**
26      * @var string
27      */
28     protected $generatorTag;
29
30     /**
31      * @var boolean
32      */
33     protected $rebuild;
34
35     /**
36      * DrupalServiceModifier constructor.
37      *
38      * @param string  $root
39      * @param string  $appRoot
40      * @param string  $serviceTag
41      * @param string  $generatorTag
42      * @param boolean $rebuild
43      */
44     public function __construct(
45         $root = null,
46         $appRoot = null,
47         $serviceTag,
48         $generatorTag,
49         $rebuild
50     ) {
51         $this->root = $root;
52         $this->appRoot = $appRoot;
53         $this->commandTag = $serviceTag;
54         $this->generatorTag = $generatorTag;
55         $this->rebuild = $rebuild;
56     }
57
58
59     /**
60      * @inheritdoc
61      */
62     public function alter(ContainerBuilder $container)
63     {
64         $container->addCompilerPass(
65             new AddServicesCompilerPass(
66                 $this->root,
67                 $this->appRoot,
68                 $this->rebuild
69             )
70         );
71         $container->addCompilerPass(
72             new FindCommandsCompilerPass($this->commandTag)
73         );
74         $container->addCompilerPass(
75             new FindGeneratorsCompilerPass($this->generatorTag)
76         );
77     }
78 }