No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PropertyInfoConstructorPass.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\PropertyInfo\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. /**
  16. * Adds extractors to the property_info.constructor_extractor service.
  17. *
  18. * @author Dmitrii Poddubnyi <dpoddubny@gmail.com>
  19. */
  20. final class PropertyInfoConstructorPass implements CompilerPassInterface
  21. {
  22. use PriorityTaggedServiceTrait;
  23. private $service;
  24. private $tag;
  25. public function __construct(string $service = 'property_info.constructor_extractor', string $tag = 'property_info.constructor_extractor')
  26. {
  27. if (0 < \func_num_args()) {
  28. trigger_deprecation('symfony/property-info', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
  29. }
  30. $this->service = $service;
  31. $this->tag = $tag;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function process(ContainerBuilder $container)
  37. {
  38. if (!$container->hasDefinition($this->service)) {
  39. return;
  40. }
  41. $definition = $container->getDefinition($this->service);
  42. $listExtractors = $this->findAndSortTaggedServices($this->tag, $container);
  43. $definition->replaceArgument(0, new IteratorArgument($listExtractors));
  44. }
  45. }