[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ -> DefinitionDecorator.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;
  13  
  14  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  15  use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
  16  
  17  /**
  18   * This definition decorates another definition.
  19   *
  20   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  21   */
  22  class DefinitionDecorator extends Definition
  23  {
  24      private $parent;
  25      private $changes;
  26  
  27      /**
  28       * @param string $parent The id of Definition instance to decorate.
  29       */
  30      public function __construct($parent)
  31      {
  32          parent::__construct();
  33  
  34          $this->parent = $parent;
  35          $this->changes = array();
  36      }
  37  
  38      /**
  39       * Returns the Definition being decorated.
  40       *
  41       * @return string
  42       */
  43      public function getParent()
  44      {
  45          return $this->parent;
  46      }
  47  
  48      /**
  49       * Returns all changes tracked for the Definition object.
  50       *
  51       * @return array An array of changes for this Definition
  52       */
  53      public function getChanges()
  54      {
  55          return $this->changes;
  56      }
  57  
  58      /**
  59       * {@inheritdoc}
  60       */
  61      public function setClass($class)
  62      {
  63          $this->changes['class'] = true;
  64  
  65          return parent::setClass($class);
  66      }
  67  
  68      /**
  69       * {@inheritdoc}
  70       */
  71      public function setFactoryClass($class)
  72      {
  73          $this->changes['factory_class'] = true;
  74  
  75          return parent::setFactoryClass($class);
  76      }
  77  
  78      /**
  79       * {@inheritdoc}
  80       */
  81      public function setFactoryMethod($method)
  82      {
  83          $this->changes['factory_method'] = true;
  84  
  85          return parent::setFactoryMethod($method);
  86      }
  87  
  88      /**
  89       * {@inheritdoc}
  90       */
  91      public function setFactoryService($service)
  92      {
  93          $this->changes['factory_service'] = true;
  94  
  95          return parent::setFactoryService($service);
  96      }
  97  
  98      /**
  99       * {@inheritdoc}
 100       */
 101      public function setConfigurator($callable)
 102      {
 103          $this->changes['configurator'] = true;
 104  
 105          return parent::setConfigurator($callable);
 106      }
 107  
 108      /**
 109       * {@inheritdoc}
 110       */
 111      public function setFile($file)
 112      {
 113          $this->changes['file'] = true;
 114  
 115          return parent::setFile($file);
 116      }
 117  
 118      /**
 119       * {@inheritdoc}
 120       */
 121      public function setPublic($boolean)
 122      {
 123          $this->changes['public'] = true;
 124  
 125          return parent::setPublic($boolean);
 126      }
 127  
 128      /**
 129       * {@inheritdoc}
 130       */
 131      public function setLazy($boolean)
 132      {
 133          $this->changes['lazy'] = true;
 134  
 135          return parent::setLazy($boolean);
 136      }
 137  
 138      /**
 139       * Gets an argument to pass to the service constructor/factory method.
 140       *
 141       * If replaceArgument() has been used to replace an argument, this method
 142       * will return the replacement value.
 143       *
 144       * @param int $index
 145       *
 146       * @return mixed The argument value
 147       *
 148       * @throws OutOfBoundsException When the argument does not exist
 149       */
 150      public function getArgument($index)
 151      {
 152          if (array_key_exists('index_'.$index, $this->arguments)) {
 153              return $this->arguments['index_'.$index];
 154          }
 155  
 156          $lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1;
 157  
 158          if ($index < 0 || $index > $lastIndex) {
 159              throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex));
 160          }
 161  
 162          return $this->arguments[$index];
 163      }
 164  
 165      /**
 166       * You should always use this method when overwriting existing arguments
 167       * of the parent definition.
 168       *
 169       * If you directly call setArguments() keep in mind that you must follow
 170       * certain conventions when you want to overwrite the arguments of the
 171       * parent definition, otherwise your arguments will only be appended.
 172       *
 173       * @param int   $index
 174       * @param mixed $value
 175       *
 176       * @return DefinitionDecorator the current instance
 177       *
 178       * @throws InvalidArgumentException when $index isn't an integer
 179       */
 180      public function replaceArgument($index, $value)
 181      {
 182          if (!is_int($index)) {
 183              throw new InvalidArgumentException('$index must be an integer.');
 184          }
 185  
 186          $this->arguments['index_'.$index] = $value;
 187  
 188          return $this;
 189      }
 190  }


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