This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php

84 lines
2.0 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Compiler;
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', RepeatedPass::class), E_USER_DEPRECATED);
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
/**
* A pass that might be run repeatedly.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @deprecated since Symfony 4.2.
*/
2011-01-17 22:28:59 +00:00
class RepeatedPass implements CompilerPassInterface
{
/**
2014-04-16 11:30:19 +01:00
* @var bool
*/
private $repeat = false;
private $passes;
2011-02-13 18:06:41 +00:00
/**
* @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
*
2012-09-17 21:41:30 +01:00
* @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
2011-02-13 18:06:41 +00:00
*/
public function __construct(array $passes)
{
foreach ($passes as $pass) {
if (!$pass instanceof RepeatablePassInterface) {
throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
}
$pass->setRepeatedPass($this);
}
$this->passes = $passes;
}
2011-02-13 18:06:41 +00:00
/**
* Process the repeatable passes that run more than once.
*/
public function process(ContainerBuilder $container)
{
2016-09-06 10:23:48 +01:00
do {
$this->repeat = false;
foreach ($this->passes as $pass) {
$pass->process($container);
}
} while ($this->repeat);
}
2011-02-13 18:06:41 +00:00
/**
2014-12-21 17:00:50 +00:00
* Sets if the pass should repeat.
2011-02-13 18:06:41 +00:00
*/
public function setRepeat()
{
$this->repeat = true;
}
2011-01-26 23:14:31 +00:00
2011-02-13 18:06:41 +00:00
/**
2014-12-21 17:00:50 +00:00
* Returns the passes.
2011-02-13 18:06:41 +00:00
*
* @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
2011-02-13 18:06:41 +00:00
*/
2011-01-26 23:14:31 +00:00
public function getPasses()
{
return $this->passes;
}
2011-06-08 11:16:48 +01:00
}