Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 558ed10

Browse filesBrowse files
committed
Move PropertyInfoPass to the PropertyInfo component
1 parent 41fd5d1 commit 558ed10
Copy full SHA for 558ed10

File tree

10 files changed

+171
-33
lines changed
Filter options

10 files changed

+171
-33
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ FrameworkBundle
8383
deprecated and will be removed in 4.0. Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass`
8484
class instead.
8585

86+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass` class has been
87+
deprecated and will be removed in 4.0. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass`
88+
class instead.
8689

8790
HttpKernel
8891
-----------

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ FrameworkBundle
187187

188188
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass` class has been
189189
removed. Use the `Symfony\Component\Form\DependencyInjection\FormPass` class instead.
190+
191+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass` class has been
192+
removed. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass`
193+
class instead.
190194

191195
* The `Symfony\Bundle\FrameworkBundle\EventListener\SessionListener` class has been removed.
192196
Use the `Symfony\Component\HttpKernel\EventListener\SessionListener` class instead.

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CHANGELOG
1919
* Deprecated `TestSessionListener`
2020
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass`.
2121
Use `Symfony\Component\Console\DependencyInjection\ConfigCachePass` instead.
22+
* Deprecated `PropertyInfoPass`, use `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` instead
2223

2324
3.2.0
2425
-----

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php
+6-30Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,17 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16-
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17-
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass instead.', PropertyInfoPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass as BasePropertyInfoPass;
1817

1918
/**
2019
* Adds extractors to the property_info service.
2120
*
2221
* @author Kévin Dunglas <dunglas@gmail.com>
22+
*
23+
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BasePropertyInfoPass instead}.
2324
*/
24-
class PropertyInfoPass implements CompilerPassInterface
25+
class PropertyInfoPass extends BasePropertyInfoPass
2526
{
26-
use PriorityTaggedServiceTrait;
27-
28-
/**
29-
* {@inheritdoc}
30-
*/
31-
public function process(ContainerBuilder $container)
32-
{
33-
if (!$container->hasDefinition('property_info')) {
34-
return;
35-
}
36-
37-
$definition = $container->getDefinition('property_info');
38-
39-
$listExtractors = $this->findAndSortTaggedServices('property_info.list_extractor', $container);
40-
$definition->replaceArgument(0, new IteratorArgument($listExtractors));
41-
42-
$typeExtractors = $this->findAndSortTaggedServices('property_info.type_extractor', $container);
43-
$definition->replaceArgument(1, new IteratorArgument($typeExtractors));
44-
45-
$descriptionExtractors = $this->findAndSortTaggedServices('property_info.description_extractor', $container);
46-
$definition->replaceArgument(2, new IteratorArgument($descriptionExtractors));
47-
48-
$accessExtractors = $this->findAndSortTaggedServices('property_info.access_extractor', $container);
49-
$definition->replaceArgument(3, new IteratorArgument($accessExtractors));
50-
}
5127
}

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass;
22-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass;
2322
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2423
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2524
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
@@ -37,6 +36,7 @@
3736
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
3837
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
3938
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
39+
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
4040
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
4141
use Symfony\Component\Debug\ErrorHandler;
4242
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -95,7 +95,7 @@ public function build(ContainerBuilder $container)
9595
$container->addCompilerPass(new TranslationDumperPass());
9696
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
9797
$this->addCompilerPassIfExists($container, SerializerPass::class);
98-
$container->addCompilerPass(new PropertyInfoPass());
98+
$this->addCompilerPassIfExists($container, PropertyInfoPass::class);
9999
$container->addCompilerPass(new DataCollectorTranslatorPass());
100100
$container->addCompilerPass(new ControllerArgumentValueResolverPass());
101101
$container->addCompilerPass(new CachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 32);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass;
1616
use Symfony\Component\DependencyInjection\Reference;
1717

18+
/**
19+
* @group legacy
20+
*/
1821
class PropertyInfoPassTest extends TestCase
1922
{
2023
public function testServicesAreOrderedAccordingToPriority()
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG
2+
=========
3+
4+
3.3.0
5+
-----
6+
7+
* Added `PropertyInfoPass`
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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\PropertyInfo\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
19+
/**
20+
* Adds extractors to the property_info service.
21+
*
22+
* @author Kévin Dunglas <dunglas@gmail.com>
23+
*/
24+
class PropertyInfoPass implements CompilerPassInterface
25+
{
26+
use PriorityTaggedServiceTrait;
27+
28+
private $propertyInfoService;
29+
private $listExtractorTag;
30+
private $typeExtractorTag;
31+
private $descriptionExtractorTag;
32+
private $accessExtractorTag;
33+
34+
public function __construct($propertyInfoService = 'property_info', $listExtractorTag = 'property_info.list_extractor', $typeExtractorTag = 'property_info.type_extractor', $descriptionExtractorTag = 'property_info.description_extractor', $accessExtractorTag = 'property_info.access_extractor')
35+
{
36+
$this->propertyInfoService = $propertyInfoService;
37+
$this->listExtractorTag = $listExtractorTag;
38+
$this->typeExtractorTag = $typeExtractorTag;
39+
$this->descriptionExtractorTag = $descriptionExtractorTag;
40+
$this->accessExtractorTag = $accessExtractorTag;
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function process(ContainerBuilder $container)
47+
{
48+
if (!$container->hasDefinition($this->propertyInfoService)) {
49+
return;
50+
}
51+
52+
$definition = $container->getDefinition($this->propertyInfoService);
53+
54+
$listExtractors = $this->findAndSortTaggedServices($this->listExtractorTag, $container);
55+
$definition->replaceArgument(0, new IteratorArgument($listExtractors));
56+
57+
$typeExtractors = $this->findAndSortTaggedServices($this->typeExtractorTag, $container);
58+
$definition->replaceArgument(1, new IteratorArgument($typeExtractors));
59+
60+
$descriptionExtractors = $this->findAndSortTaggedServices($this->descriptionExtractorTag, $container);
61+
$definition->replaceArgument(2, new IteratorArgument($descriptionExtractors));
62+
63+
$accessExtractors = $this->findAndSortTaggedServices($this->accessExtractorTag, $container);
64+
$definition->replaceArgument(3, new IteratorArgument($accessExtractors));
65+
}
66+
}
+76Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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\PropertyInfo\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\Reference;
16+
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
17+
18+
class PropertyInfoPassTest extends TestCase
19+
{
20+
public function testServicesAreOrderedAccordingToPriority()
21+
{
22+
$services = array(
23+
'n3' => array('tag' => array()),
24+
'n1' => array('tag' => array('priority' => 200)),
25+
'n2' => array('tag' => array('priority' => 100)),
26+
);
27+
28+
$expected = array(
29+
new Reference('n1'),
30+
new Reference('n2'),
31+
new Reference('n3'),
32+
);
33+
34+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
35+
36+
$container
37+
->expects($this->any())
38+
->method('findTaggedServiceIds')
39+
->will($this->returnValue($services));
40+
41+
$propertyInfoPass = new PropertyInfoPass();
42+
43+
$method = new \ReflectionMethod(
44+
'Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass',
45+
'findAndSortTaggedServices'
46+
);
47+
$method->setAccessible(true);
48+
49+
$actual = $method->invoke($propertyInfoPass, 'tag', $container);
50+
51+
$this->assertEquals($expected, $actual);
52+
}
53+
54+
public function testReturningEmptyArrayWhenNoService()
55+
{
56+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
57+
58+
$container
59+
->expects($this->any())
60+
->method('findTaggedServiceIds')
61+
->will($this->returnValue(array()))
62+
;
63+
64+
$propertyInfoPass = new PropertyInfoPass();
65+
66+
$method = new \ReflectionMethod(
67+
'Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass',
68+
'findAndSortTaggedServices'
69+
);
70+
$method->setAccessible(true);
71+
72+
$actual = $method->invoke($propertyInfoPass, 'tag', $container);
73+
74+
$this->assertEquals(array(), $actual);
75+
}
76+
}

‎src/Symfony/Component/PropertyInfo/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/composer.json
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
"require-dev": {
3030
"symfony/serializer": "~2.8|~3.0",
3131
"symfony/cache": "~3.1",
32+
"symfony/dependency-injection": "~3.3",
3233
"phpdocumentor/reflection-docblock": "^3.0",
3334
"doctrine/annotations": "~1.0"
3435
},
3536
"conflict": {
3637
"phpdocumentor/reflection-docblock": "<3.0",
37-
"phpdocumentor/type-resolver": "<0.2.0"
38+
"phpdocumentor/type-resolver": "<0.2.0",
39+
"symfony/dependency-injection": "<3.3"
3840
},
3941
"suggest": {
4042
"psr/cache-implementation": "To cache results",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.