File tree 5 files changed +81
-1
lines changed
src/Symfony/Component/Routing
Fixtures/Psr4Controllers/SubNamespace
5 files changed +81
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ function (\SplFileInfo $current) {
83
83
84
84
continue ;
85
85
}
86
- if ('php ' !== $ file ->getExtension () || !class_exists ($ className = $ psr4Prefix .'\\' .$ file ->getBasename ('.php ' ))) {
86
+ if ('php ' !== $ file ->getExtension () || !class_exists ($ className = $ psr4Prefix .'\\' .$ file ->getBasename ('.php ' )) || ( new \ ReflectionClass ( $ className ))-> isAbstract () ) {
<
8000
/code>
87
87
continue ;
88
88
}
89
89
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace ;
13
+
14
+ use Symfony \Component \HttpFoundation \Response ;
15
+
16
+ /**
17
+ * An irrelevant class.
18
+ *
19
+ * This fixture is not referenced anywhere. Its presence makes sure, classes without attributes are silently ignored
20
+ * when loading routes from a directory.
21
+ */
22
+ final class IrrelevantClass
23
+ {
24
+ public function irrelevantAction (): Response
25
+ {
26
+ return new Response (status: Response::HTTP_NO_CONTENT );
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace ;
13
+
14
+ use Symfony \Component \HttpFoundation \Response ;
15
+ use Symfony \Component \Routing \Annotation \Route ;
16
+
17
+ abstract class MyAbstractController
18
+ {
19
+ #[Route('/a/route/from/an/abstract/controller ' , name: 'from_abstract ' )]
20
+ public function someAction (): Response
21
+ {
22
+ return new Response (status: Response::HTTP_NO_CONTENT );
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace ;
13
+
14
+ use Symfony \Component \Routing \Annotation \Route ;
15
+
16
+ #[Route('/my/child/controller ' , name: 'my_child_controller_ ' )]
17
+ final class MyChildController extends MyAbstractController
18
+ {
19
+ }
Original file line number Diff line number Diff line change 21
21
use Symfony \Component \Routing \RouteCollection ;
22
22
use Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \MyController ;
23
23
use Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace \EvenDeeperNamespace \MyOtherController ;
24
+ use Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace \MyChildController ;
24
25
use Symfony \Component \Routing \Tests \Fixtures \Psr4Controllers \SubNamespace \MyControllerWithATrait ;
25
26
26
27
class Psr4DirectoryLoaderTest extends TestCase
@@ -56,6 +57,14 @@ public function testTraitController()
56
57
$ this ->assertSame (MyControllerWithATrait::class.'::someAction ' , $ route ->getDefault ('_controller ' ));
57
58
}
58
59
60
+ public function testAbstractController ()
61
+ {
62
+ $ route = $ this ->loadPsr4Controllers ()->get ('my_child_controller_from_abstract ' );
63
+
64
+ $ this ->assertSame ('/my/child/controller/a/route/from/an/abstract/controller ' , $ route ->getPath ());
65
+ $ this ->assertSame (MyChildController::class.'::someAction ' , $ route ->getDefault ('_controller ' ));
66
+ }
67
+
59
68
/**
60
69
* @dataProvider provideNamespacesThatNeedTrimming
61
70
*/
You can’t perform that action at this time.
0 commit comments