[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/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      /**
  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          $this->repeat = false;
  60          foreach ($this->passes as $pass) {
  61              $pass->process($container);
  62          }
  63  
  64          if ($this->repeat) {
  65              $this->process($container);
  66          }
  67      }
  68  
  69      /**
  70       * Sets if the pass should repeat.
  71       */
  72      public function setRepeat()
  73      {
  74          $this->repeat = true;
  75      }
  76  
  77      /**
  78       * Returns the passes.
  79       *
  80       * @return RepeatablePassInterface[] An array of RepeatablePassInterface objects
  81       */
  82      public function getPasses()
  83      {
  84          return $this->passes;
  85      }
  86  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1