File tree 3 files changed +55
-5
lines changed
src/Symfony/Bundle/FrameworkBundle
3 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 56
56
</service >
57
57
58
58
<service id =" routing.loader" class =" %routing.loader.class%" >
59
- <tag name =" monolog.logger" channel =" router" />
60
59
<argument type =" service" id =" controller_name_converter" />
61
- <argument type =" service" id =" logger" on-invalid =" null" />
62
60
<argument type =" service" id =" routing.resolver" />
63
61
</service >
64
62
Original file line number Diff line number Diff line change @@ -34,14 +34,21 @@ class DelegatingLoader extends BaseDelegatingLoader
34
34
/**
35
35
* Constructor.
36
36
*
37
+ * Ability to pass a LoggerInterface instance as second argument will be removed in 3.0.
38
+ *
37
39
* @param ControllerNameParser $parser A ControllerNameParser instance
38
- * @param LoggerInterface $logger A LoggerInterface instance
39
40
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
40
41
*/
41
- public function __construct (ControllerNameParser $ parser , LoggerInterface $ logger = null , LoaderResolverInterface $ resolver )
42
+ public function __construct (ControllerNameParser $ parser , $ resolver , $ r = null )
42
43
{
43
44
$ this ->parser = $ parser ;
44
- $ this ->logger = $ logger ;
45
+
46
+ if (!$ resolver instanceof LoaderResolverInterface) {
47
+ $ this ->logger = $ resolver ;
48
+ $ resolver = $ r ;
49
+
50
+ @trigger_error ('Passing a LoggerInterface instance a second argument of the ' .__METHOD__ .' method is deprecated since version 2.8 and will not be supported anymore in 3.0. ' , E_USER_DEPRECATED );
51
+ }
45
52
46
53
parent ::__construct ($ resolver );
47
54
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Bundle \FrameworkBundle \Tests \Routing ;
4
+
5
+ use Psr \Log \NullLogger ;
6
+ use Symfony \Bundle \FrameworkBundle \Controller \ControllerNameParser ;
7
+ use Symfony \Bundle \FrameworkBundle \Routing \DelegatingLoader ;
8
+ use Symfony \Component \Config \Loader \LoaderResolver ;
9
+
10
+ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /** @var ControllerNameParser */
13
+ private $ controllerNameParser ;
14
+
15
+ public function setUp ()
16
+ {
17
+ $ this ->controllerNameParser = $ this ->getMockBuilder ('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser ' )
18
+ ->disableOriginalConstructor ()
19
+ ->getMock ();
20
+ }
21
+
22
+ /**
23
+ * @group legacy
24
+ */
25
+ public function testLegacyConstructorApi ()
26
+ {
27
+ new DelegatingLoader ($ this ->controllerNameParser , new NullLogger (), new LoaderResolver ());
28
+ $ this ->assertTrue (true , '__construct() accepts a LoggerInterface instance as its second argument ' );
29
+ }
30
+
31
+ /**
32
+ * @group legacy
33
+ */
34
+ public function testLegacyConstructorApiAcceptsNullAsSecondArgument ()
35
+ {
36
+ new DelegatingLoader ($ this ->controllerNameParser , null , new LoaderResolver ());
37
+ $ this ->assertTrue (true , '__construct() accepts null as its second argument ' );
38
+ }
39
+
40
+ public function testConstructorApi ()
41
+ {
42
+ new DelegatingLoader ($ this ->controllerNameParser , new LoaderResolver ());
43
+ $ this ->assertTrue (true , '__construct() takes a ControllerNameParser and LoaderResolverInterface respectively as its first and second argument. ' );
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments