vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\DependencyInjection\Argument;
  11. /**
  12.  * Represents a collection of services found by tag name to lazily iterate over.
  13.  *
  14.  * @author Roland Franssen <franssen.roland@gmail.com>
  15.  */
  16. class TaggedIteratorArgument extends IteratorArgument
  17. {
  18.     private $tag;
  19.     private $indexAttribute;
  20.     private $defaultIndexMethod;
  21.     private $defaultPriorityMethod;
  22.     private $needsIndexes false;
  23.     /**
  24.      * @param string      $tag                   The name of the tag identifying the target services
  25.      * @param string|null $indexAttribute        The name of the attribute that defines the key referencing each service in the tagged collection
  26.      * @param string|null $defaultIndexMethod    The static method that should be called to get each service's key when their tag doesn't define the previous attribute
  27.      * @param bool        $needsIndexes          Whether indexes are required and should be generated when computing the map
  28.      * @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
  29.      */
  30.     public function __construct(string $tagstring $indexAttribute nullstring $defaultIndexMethod nullbool $needsIndexes falsestring $defaultPriorityMethod null)
  31.     {
  32.         parent::__construct([]);
  33.         if (null === $indexAttribute && $needsIndexes) {
  34.             $indexAttribute preg_match('/[^.]++$/'$tag$m) ? $m[0] : $tag;
  35.         }
  36.         $this->tag $tag;
  37.         $this->indexAttribute $indexAttribute;
  38.         $this->defaultIndexMethod $defaultIndexMethod ?: ($indexAttribute 'getDefault'.str_replace(' '''ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/'' '$indexAttribute))).'Name' null);
  39.         $this->needsIndexes $needsIndexes;
  40.         $this->defaultPriorityMethod $defaultPriorityMethod ?: ($indexAttribute 'getDefault'.str_replace(' '''ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/'' '$indexAttribute))).'Priority' null);
  41.     }
  42.     public function getTag()
  43.     {
  44.         return $this->tag;
  45.     }
  46.     public function getIndexAttribute(): ?string
  47.     {
  48.         return $this->indexAttribute;
  49.     }
  50.     public function getDefaultIndexMethod(): ?string
  51.     {
  52.         return $this->defaultIndexMethod;
  53.     }
  54.     public function needsIndexes(): bool
  55.     {
  56.         return $this->needsIndexes;
  57.     }
  58.     public function getDefaultPriorityMethod(): ?string
  59.     {
  60.         return $this->defaultPriorityMethod;
  61.     }
  62. }