[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ -> PassConfig.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\Exception\InvalidArgumentException;
  15  
  16  /**
  17   * Compiler Pass Configuration.
  18   *
  19   * This class has a default configuration embedded.
  20   *
  21   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  22   */
  23  class PassConfig
  24  {
  25      const TYPE_AFTER_REMOVING = 'afterRemoving';
  26      const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization';
  27      const TYPE_BEFORE_REMOVING = 'beforeRemoving';
  28      const TYPE_OPTIMIZE = 'optimization';
  29      const TYPE_REMOVE = 'removing';
  30  
  31      private $mergePass;
  32      private $afterRemovingPasses;
  33      private $beforeOptimizationPasses;
  34      private $beforeRemovingPasses;
  35      private $optimizationPasses;
  36      private $removingPasses;
  37  
  38      public function __construct()
  39      {
  40          $this->mergePass = new MergeExtensionConfigurationPass();
  41  
  42          $this->afterRemovingPasses = array();
  43          $this->beforeOptimizationPasses = array();
  44          $this->beforeRemovingPasses = array();
  45  
  46          $this->optimizationPasses = array(
  47              new ResolveDefinitionTemplatesPass(),
  48              new ResolveParameterPlaceHoldersPass(),
  49              new CheckDefinitionValidityPass(),
  50              new ResolveReferencesToAliasesPass(),
  51              new ResolveInvalidReferencesPass(),
  52              new AnalyzeServiceReferencesPass(true),
  53              new CheckCircularReferencesPass(),
  54              new CheckReferenceValidityPass(),
  55          );
  56  
  57          $this->removingPasses = array(
  58              new RemovePrivateAliasesPass(),
  59              new ReplaceAliasByActualDefinitionPass(),
  60              new RemoveAbstractDefinitionsPass(),
  61              new RepeatedPass(array(
  62                  new AnalyzeServiceReferencesPass(),
  63                  new InlineServiceDefinitionsPass(),
  64                  new AnalyzeServiceReferencesPass(),
  65                  new RemoveUnusedDefinitionsPass(),
  66              )),
  67              new CheckExceptionOnInvalidReferenceBehaviorPass(),
  68          );
  69      }
  70  
  71      /**
  72       * Returns all passes in order to be processed.
  73       *
  74       * @return array An array of all passes to process
  75       */
  76      public function getPasses()
  77      {
  78          return array_merge(
  79              array($this->mergePass),
  80              $this->beforeOptimizationPasses,
  81              $this->optimizationPasses,
  82              $this->beforeRemovingPasses,
  83              $this->removingPasses,
  84              $this->afterRemovingPasses
  85          );
  86      }
  87  
  88      /**
  89       * Adds a pass.
  90       *
  91       * @param CompilerPassInterface $pass A Compiler pass
  92       * @param string                $type The pass type
  93       *
  94       * @throws InvalidArgumentException when a pass type doesn't exist
  95       */
  96      public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION)
  97      {
  98          $property = $type.'Passes';
  99          if (!isset($this->$property)) {
 100              throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
 101          }
 102  
 103          $this->{$property}[] = $pass;
 104      }
 105  
 106      /**
 107       * Gets all passes for the AfterRemoving pass.
 108       *
 109       * @return array An array of passes
 110       */
 111      public function getAfterRemovingPasses()
 112      {
 113          return $this->afterRemovingPasses;
 114      }
 115  
 116      /**
 117       * Gets all passes for the BeforeOptimization pass.
 118       *
 119       * @return array An array of passes
 120       */
 121      public function getBeforeOptimizationPasses()
 122      {
 123          return $this->beforeOptimizationPasses;
 124      }
 125  
 126      /**
 127       * Gets all passes for the BeforeRemoving pass.
 128       *
 129       * @return array An array of passes
 130       */
 131      public function getBeforeRemovingPasses()
 132      {
 133          return $this->beforeRemovingPasses;
 134      }
 135  
 136      /**
 137       * Gets all passes for the Optimization pass.
 138       *
 139       * @return array An array of passes
 140       */
 141      public function getOptimizationPasses()
 142      {
 143          return $this->optimizationPasses;
 144      }
 145  
 146      /**
 147       * Gets all passes for the Removing pass.
 148       *
 149       * @return array An array of passes
 150       */
 151      public function getRemovingPasses()
 152      {
 153          return $this->removingPasses;
 154      }
 155  
 156      /**
 157       * Gets all passes for the Merge pass.
 158       *
 159       * @return array An array of passes
 160       */
 161      public function getMergePass()
 162      {
 163          return $this->mergePass;
 164      }
 165  
 166      /**
 167       * Sets the Merge Pass.
 168       *
 169       * @param CompilerPassInterface $pass The merge pass
 170       */
 171      public function setMergePass(CompilerPassInterface $pass)
 172      {
 173          $this->mergePass = $pass;
 174      }
 175  
 176      /**
 177       * Sets the AfterRemoving passes.
 178       *
 179       * @param array $passes An array of passes
 180       */
 181      public function setAfterRemovingPasses(array $passes)
 182      {
 183          $this->afterRemovingPasses = $passes;
 184      }
 185  
 186      /**
 187       * Sets the BeforeOptimization passes.
 188       *
 189       * @param array $passes An array of passes
 190       */
 191      public function setBeforeOptimizationPasses(array $passes)
 192      {
 193          $this->beforeOptimizationPasses = $passes;
 194      }
 195  
 196      /**
 197       * Sets the BeforeRemoving passes.
 198       *
 199       * @param array $passes An array of passes
 200       */
 201      public function setBeforeRemovingPasses(array $passes)
 202      {
 203          $this->beforeRemovingPasses = $passes;
 204      }
 205  
 206      /**
 207       * Sets the Optimization passes.
 208       *
 209       * @param array $passes An array of passes
 210       */
 211      public function setOptimizationPasses(array $passes)
 212      {
 213          $this->optimizationPasses = $passes;
 214      }
 215  
 216      /**
 217       * Sets the Removing passes.
 218       *
 219       * @param array $passes An array of passes
 220       */
 221      public function setRemovingPasses(array $passes)
 222      {
 223          $this->removingPasses = $passes;
 224      }
 225  }


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