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 c839532

Browse filesBrowse files
committed
Merge branch '2.7' into 2.8
* 2.7: Prevent double registrations related to tag priorities
2 parents 6edd08d + 92eb9e1 commit c839532
Copy full SHA for c839532

File tree

Expand file treeCollapse file tree

3 files changed

+17
-23
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-23
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container
5757
}
5858

5959
$sortedServices = array();
60-
foreach ($services as $serviceId => $tags) {
61-
foreach ($tags as $attributes) {
62-
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
63-
$sortedServices[$priority][] = new Reference($serviceId);
64-
}
60+
foreach ($services as $serviceId => $attributes) {
61+
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
62+
$sortedServices[$priority][] = new Reference($serviceId);
6563
}
6664

6765
krsort($sortedServices);

‎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
@@ -72,9 +72,9 @@ public function testThrowExceptionWhenNoEncoders()
7272
public function testServicesAreOrderedAccordingToPriority()
7373
{
7474
$services = array(
75-
'n3' => array('tag' => array()),
76-
'n1' => array('tag' => array('priority' => 200)),
77-
'n2' => array('tag' => array('priority' => 100)),
75+
'n3' => array(array()),
76+
'n1' => array(array('priority' => 200)),
77+
'n2' => array(array('priority' => 100)),
7878
);
7979

8080
$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) {

0 commit comments

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