4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Compiler;
14 use Symfony\Component\DependencyInjection\ContainerBuilder;
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18 * A pass that might be run repeatedly.
20 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
22 class RepeatedPass implements CompilerPassInterface
27 private $repeat = false;
32 * @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
34 * @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
36 public function __construct(array $passes)
38 foreach ($passes as $pass) {
39 if (!$pass instanceof RepeatablePassInterface) {
40 throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
43 $pass->setRepeatedPass($this);
46 $this->passes = $passes;
50 * Process the repeatable passes that run more than once.
52 public function process(ContainerBuilder $container)
55 $this->repeat = false;
56 foreach ($this->passes as $pass) {
57 $pass->process($container);
59 } while ($this->repeat);
63 * Sets if the pass should repeat.
65 public function setRepeat()
73 * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
75 public function getPasses()