File tree Expand file tree Collapse file tree 3 files changed +17
-21
lines changed
FrameworkBundle/Tests/DependencyInjection/Compiler
TwigBundle/DependencyInjection/Compiler Expand file tree Collapse file tree 3 files changed +17
-21
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ class PropertyInfoPassTest extends TestCase
20
20
public function testServicesAreOrderedAccordingToPriority ()
21
21
{
22
22
$ services = array (
23
- 'n3 ' => array (' tag ' => array ()),
24
- 'n1 ' => array (' tag ' => array ('priority ' => 200 )),
25
- 'n2 ' => array (' tag ' => array ('priority ' => 100 )),
23
+ 'n3 ' => array (array ()),
24
+ 'n1 ' => array (array ('priority ' => 200 )),
25
+ 'n2 ' => array (array ('priority ' => 100 )),
26
26
);
27
27
28
28
$ expected = array (
Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ public function testThrowExceptionWhenNoEncoders()
72
72
public function testServicesAreOrderedAccordingToPriority ()
73
73
{
74
74
$ 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 )),
78
78
);
79
79
80
80
$ expected = array (
Original file line number Diff line number Diff line change @@ -29,27 +29,23 @@ public function process(ContainerBuilder $container)
29
29
return ;
30
30
}
31
31
32
- // register additional template loaders
33
- $ loaderIds = $ container -> findTaggedServiceIds ( ' twig.loader ' ) ;
32
+ $ prioritizedLoaders = array ();
33
+ $ found = 0 ;
34
34
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 ) {
36
42
throw new LogicException ('No twig loaders found. You need to tag at least one loader with "twig.loader" ' );
37
43
}
38
44
39
- if (count ( $ loaderIds ) === 1 ) {
40
- $ container ->setAlias ('twig.loader ' , key ( $ loaderIds ) );
45
+ if (1 === $ found ) {
46
+ $ container ->setAlias ('twig.loader ' , $ id );
41
47
} else {
42
48
$ 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
-
53
49
krsort ($ prioritizedLoaders );
54
50
55
51
foreach ($ prioritizedLoaders as $ loaders ) {
You can’t perform that action at this time.
0 commit comments