Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/RepeatedPass.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\DependencyInjection\Compiler; | |
13 | |
14 use Symfony\Component\DependencyInjection\ContainerBuilder; | |
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | |
16 | |
17 /** | |
18 * A pass that might be run repeatedly. | |
19 * | |
20 * @author Johannes M. Schmitt <schmittjoh@gmail.com> | |
21 */ | |
22 class RepeatedPass implements CompilerPassInterface | |
23 { | |
24 /** | |
25 * @var bool | |
26 */ | |
27 private $repeat = false; | |
28 | |
29 /** | |
30 * @var RepeatablePassInterface[] | |
31 */ | |
32 private $passes; | |
33 | |
34 /** | |
35 * @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects | |
36 * | |
37 * @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface | |
38 */ | |
39 public function __construct(array $passes) | |
40 { | |
41 foreach ($passes as $pass) { | |
42 if (!$pass instanceof RepeatablePassInterface) { | |
43 throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.'); | |
44 } | |
45 | |
46 $pass->setRepeatedPass($this); | |
47 } | |
48 | |
49 $this->passes = $passes; | |
50 } | |
51 | |
52 /** | |
53 * Process the repeatable passes that run more than once. | |
54 * | |
55 * @param ContainerBuilder $container | |
56 */ | |
57 public function process(ContainerBuilder $container) | |
58 { | |
59 do { | |
60 $this->repeat = false; | |
61 foreach ($this->passes as $pass) { | |
62 $pass->process($container); | |
63 } | |
64 } while ($this->repeat); | |
65 } | |
66 | |
67 /** | |
68 * Sets if the pass should repeat. | |
69 */ | |
70 public function setRepeat() | |
71 { | |
72 $this->repeat = true; | |
73 } | |
74 | |
75 /** | |
76 * Returns the passes. | |
77 * | |
78 * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects | |
79 */ | |
80 public function getPasses() | |
81 { | |
82 return $this->passes; | |
83 } | |
84 } |