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;
30 * @var RepeatablePassInterface[]
35 * @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
37 * @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
39 public function __construct(array $passes)
41 foreach ($passes as $pass) {
42 if (!$pass instanceof RepeatablePassInterface) {
43 throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
46 $pass->setRepeatedPass($this);
49 $this->passes = $passes;
53 * Process the repeatable passes that run more than once.
55 * @param ContainerBuilder $container
57 public function process(ContainerBuilder $container)
60 $this->repeat = false;
61 foreach ($this->passes as $pass) {
62 $pass->process($container);
64 } while ($this->repeat);
68 * Sets if the pass should repeat.
70 public function setRepeat()
78 * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
80 public function getPasses()