Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
21 / 21
PropertyInfoPass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
21 / 21
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
7 / 7
 process
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
14 / 14
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
12namespace Symfony\Component\PropertyInfo\DependencyInjection;
13
14use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19/**
20 * Adds extractors to the property_info service.
21 *
22 * @author K√©vin Dunglas <dunglas@gmail.com>
23 */
24class PropertyInfoPass implements CompilerPassInterface
25{
26    use PriorityTaggedServiceTrait;
27
28    private $propertyInfoService;
29    private $listExtractorTag;
30    private $typeExtractorTag;
31    private $descriptionExtractorTag;
32    private $accessExtractorTag;
33    private $initializableExtractorTag;
34
35    public function __construct(string $propertyInfoService = 'property_info', string $listExtractorTag = 'property_info.list_extractor', string $typeExtractorTag = 'property_info.type_extractor', string $descriptionExtractorTag = 'property_info.description_extractor', string $accessExtractorTag = 'property_info.access_extractor', string $initializableExtractorTag = 'property_info.initializable_extractor')
36    {
37        $this->propertyInfoService = $propertyInfoService;
38        $this->listExtractorTag = $listExtractorTag;
39        $this->typeExtractorTag = $typeExtractorTag;
40        $this->descriptionExtractorTag = $descriptionExtractorTag;
41        $this->accessExtractorTag = $accessExtractorTag;
42        $this->initializableExtractorTag = $initializableExtractorTag;
43    }
44
45    /**
46     * {@inheritdoc}
47     */
48    public function process(ContainerBuilder $container)
49    {
50        if (!$container->hasDefinition($this->propertyInfoService)) {
51            return;
52        }
53
54        $definition = $container->getDefinition($this->propertyInfoService);
55
56        $listExtractors = $this->findAndSortTaggedServices($this->listExtractorTag, $container);
57        $definition->replaceArgument(0, new IteratorArgument($listExtractors));
58
59        $typeExtractors = $this->findAndSortTaggedServices($this->typeExtractorTag, $container);
60        $definition->replaceArgument(1, new IteratorArgument($typeExtractors));
61
62        $descriptionExtractors = $this->findAndSortTaggedServices($this->descriptionExtractorTag, $container);
63        $definition->replaceArgument(2, new IteratorArgument($descriptionExtractors));
64
65        $accessExtractors = $this->findAndSortTaggedServices($this->accessExtractorTag, $container);
66        $definition->replaceArgument(3, new IteratorArgument($accessExtractors));
67
68        $initializableExtractors = $this->findAndSortTaggedServices($this->initializableExtractorTag, $container);
69        $definition->setArgument(4, new IteratorArgument($initializableExtractors));
70    }
71}