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 3deeb0c

Browse filesBrowse files
Merge branch '3.2'
* 3.2: [2.8] Prevent double registrations related to tag priorities Prevent double registrations related to tag priorities [3.2] Prevent double registrations related to tag priorities
2 parents f24a1a8 + 766ae29 commit 3deeb0c
Copy full SHA for 3deeb0c

File tree

Expand file treeCollapse file tree

4 files changed

+20
-26
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+20
-26
lines changed

‎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
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class PropertyInfoPassTest extends TestCase
2323
public function testServicesAreOrderedAccordingToPriority()
2424
{
2525
$services = array(
26-
'n3' => array('tag' => array()),
27-
'n1' => array('tag' => array('priority' => 200)),
28-
'n2' => array('tag' => array('priority' => 100)),
26+
'n3' => array(array()),
27+
'n1' => array(array('priority' => 200)),
28+
'n2' => array(array('priority' => 100)),
2929
);
3030

3131
$expected = array(

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public function testThrowExceptionWhenNoEncoders()
7474
public function testServicesAreOrderedAccordingToPriority()
7575
{
7676
$services = array(
77-
'n3' => array('tag' => array()),
78-
'n1' => array('tag' => array('priority' => 200)),
79-
'n2' => array('tag' => array('priority' => 100)),
77+
'n3' => array(array()),
78+
'n1' => array(array('priority' => 200)),
79+
'n2' => array(array('priority' => 100)),
8080
);
8181

8282
$expected = array(

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php
+11-15Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,23 @@ public function process(ContainerBuilder $container)
2929
return;
3030
}
3131

32-
// register additional template loaders
33-
$loaderIds = $container->findTaggedServiceIds('twig.loader');
32+
$prioritizedLoaders = array();
33+
$found = 0;
3434

35-
if (count($loaderIds) === 0) {
35+
foreach ($container->findTaggedServiceIds('twig.loader') as $id => $attributes) {
36+
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
37+
$prioritizedLoaders[$priority][] = $id;
38+
++$found;
39+
}
40+
41+
if (!$found) {
3642
throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader"');
3743
}
3844

39-
if (count($loaderIds) === 1) {
40-
$container->setAlias('twig.loader', key($loaderIds));
45+
if (1 === $found) {
46+
$container->setAlias('twig.loader', $id);
4147
} else {
4248
$chainLoader = $container->getDefinition('twig.loader.chain');
43-
44-
$prioritizedLoaders = array();
45-
46-
foreach ($loaderIds as $id => $tags) {
47-
foreach ($tags as $tag) {
48-
$priority = isset($tag['priority']) ? $tag['priority'] : 0;
49-
$prioritizedLoaders[$priority][] = $id;
50-
}
51-
}
52-
5349
krsort($prioritizedLoaders);
5450

5551
foreach ($prioritizedLoaders as $loaders) {

‎src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container
4040
{
4141
$services = array();
4242

43-
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
44-
foreach ($tags as $attributes) {
45-
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
46-
$services[$priority][] = new Reference($serviceId);
47-
}
43+
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $attributes) {
44+
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
45+
$services[$priority][] = new Reference($serviceId);
4846
}
4947

5048
if ($services) {

0 commit comments

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