[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Compiler/ -> RepeatedPass.php (source)

   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      private $passes;
  30  
  31      /**
  32       * @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
  33       *
  34       * @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
  35       */
  36      public function __construct(array $passes)
  37      {
  38          foreach ($passes as $pass) {
  39              if (!$pass instanceof RepeatablePassInterface) {
  40                  throw new InvalidArgumentException('$passes must be an array of RepeatablePassInterface.');
  41              }
  42  
  43              $pass->setRepeatedPass($this);
  44          }
  45  
  46          $this->passes = $passes;
  47      }
  48  
  49      /**
  50       * Process the repeatable passes that run more than once.
  51       */
  52      public function process(ContainerBuilder $container)
  53      {
  54          do {
  55              $this->repeat = false;
  56              foreach ($this->passes as $pass) {
  57                  $pass->process($container);
  58              }
  59          } while ($this->repeat);
  60      }
  61  
  62      /**
  63       * Sets if the pass should repeat.
  64       */
  65      public function setRepeat()
  66      {
  67          $this->repeat = true;
  68      }
  69  
  70      /**
  71       * Returns the passes.
  72       *
  73       * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
  74       */
  75      public function getPasses()
  76      {
  77          return $this->passes;
  78      }
  79  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1