[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/ -> ChildDefinition.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\BadMethodCallException;
  15  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  16  use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
  17  
  18  /**
  19   * This definition extends another definition.
  20   *
  21   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  22   */
  23  class ChildDefinition extends Definition
  24  {
  25      private $parent;
  26  
  27      /**
  28       * @param string $parent The id of Definition instance to decorate
  29       */
  30      public function __construct($parent)
  31      {
  32          $this->parent = $parent;
  33          $this->setPrivate(false);
  34      }
  35  
  36      /**
  37       * Returns the Definition to inherit from.
  38       *
  39       * @return string
  40       */
  41      public function getParent()
  42      {
  43          return $this->parent;
  44      }
  45  
  46      /**
  47       * Sets the Definition to inherit from.
  48       *
  49       * @param string $parent
  50       *
  51       * @return $this
  52       */
  53      public function setParent($parent)
  54      {
  55          $this->parent = $parent;
  56  
  57          return $this;
  58      }
  59  
  60      /**
  61       * Gets an argument to pass to the service constructor/factory method.
  62       *
  63       * If replaceArgument() has been used to replace an argument, this method
  64       * will return the replacement value.
  65       *
  66       * @param int|string $index
  67       *
  68       * @return mixed The argument value
  69       *
  70       * @throws OutOfBoundsException When the argument does not exist
  71       */
  72      public function getArgument($index)
  73      {
  74          if (\array_key_exists('index_'.$index, $this->arguments)) {
  75              return $this->arguments['index_'.$index];
  76          }
  77  
  78          return parent::getArgument($index);
  79      }
  80  
  81      /**
  82       * You should always use this method when overwriting existing arguments
  83       * of the parent definition.
  84       *
  85       * If you directly call setArguments() keep in mind that you must follow
  86       * certain conventions when you want to overwrite the arguments of the
  87       * parent definition, otherwise your arguments will only be appended.
  88       *
  89       * @param int|string $index
  90       * @param mixed      $value
  91       *
  92       * @return $this
  93       *
  94       * @throws InvalidArgumentException when $index isn't an integer
  95       */
  96      public function replaceArgument($index, $value)
  97      {
  98          if (\is_int($index)) {
  99              $this->arguments['index_'.$index] = $value;
 100          } elseif (0 === strpos($index, '$')) {
 101              $this->arguments[$index] = $value;
 102          } else {
 103              throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.');
 104          }
 105  
 106          return $this;
 107      }
 108  
 109      /**
 110       * @internal
 111       */
 112      public function setAutoconfigured($autoconfigured)
 113      {
 114          throw new BadMethodCallException('A ChildDefinition cannot be autoconfigured.');
 115      }
 116  
 117      /**
 118       * @internal
 119       */
 120      public function setInstanceofConditionals(array $instanceof)
 121      {
 122          throw new BadMethodCallException('A ChildDefinition cannot have instanceof conditionals set on it.');
 123      }
 124  }
 125  
 126  class_alias(ChildDefinition::class, DefinitionDecorator::class);


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1