diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 0bfee565f5..5f767a48e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -23,9 +23,9 @@ class PropertyInfoPassTest extends TestCase public function testServicesAreOrderedAccordingToPriority() { $services = array( - 'n3' => array('tag' => array()), - 'n1' => array('tag' => array('priority' => 200)), - 'n2' => array('tag' => array('priority' => 100)), + 'n3' => array(array()), + 'n1' => array(array('priority' => 200)), + 'n2' => array(array('priority' => 100)), ); $expected = array( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php index 29aabf5e1d..0dd339e73f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php @@ -74,9 +74,9 @@ class SerializerPassTest extends TestCase public function testServicesAreOrderedAccordingToPriority() { $services = array( - 'n3' => array('tag' => array()), - 'n1' => array('tag' => array('priority' => 200)), - 'n2' => array('tag' => array('priority' => 100)), + 'n3' => array(array()), + 'n1' => array(array('priority' => 200)), + 'n2' => array(array('priority' => 100)), ); $expected = array( diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php index bc3b71c696..fc670e7cd1 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php @@ -29,27 +29,23 @@ class TwigLoaderPass implements CompilerPassInterface return; } - // register additional template loaders - $loaderIds = $container->findTaggedServiceIds('twig.loader'); + $prioritizedLoaders = array(); + $found = 0; - if (count($loaderIds) === 0) { + foreach ($container->findTaggedServiceIds('twig.loader') as $id => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $prioritizedLoaders[$priority][] = $id; + ++$found; + } + + if (!$found) { throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader"'); } - if (count($loaderIds) === 1) { - $container->setAlias('twig.loader', key($loaderIds)); + if (1 === $found) { + $container->setAlias('twig.loader', $id); } else { $chainLoader = $container->getDefinition('twig.loader.chain'); - - $prioritizedLoaders = array(); - - foreach ($loaderIds as $id => $tags) { - foreach ($tags as $tag) { - $priority = isset($tag['priority']) ? $tag['priority'] : 0; - $prioritizedLoaders[$priority][] = $id; - } - } - krsort($prioritizedLoaders); foreach ($prioritizedLoaders as $loaders) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php index 83f6014c39..64c041e93f 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php @@ -40,11 +40,9 @@ trait PriorityTaggedServiceTrait { $services = array(); - foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) { - foreach ($tags as $attributes) { - $priority = isset($attributes['priority']) ? $attributes['priority'] : 0; - $services[$priority][] = new Reference($serviceId); - } + foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $services[$priority][] = new Reference($serviceId); } if ($services) {