@@ -61,11 +61,11 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
61
61
$ route ->getMethods () ? implode ('| ' , $ route ->getMethods ()) : 'ANY ' ,
62
62
$ route ->getSchemes () ? implode ('| ' , $ route ->getSchemes ()) : 'ANY ' ,
63
63
'' !== $ route ->getHost () ? $ route ->getHost () : 'ANY ' ,
64
- $ this ->formatControllerLink ($ controller , $ route ->getPath ()),
64
+ $ this ->formatControllerLink ($ controller , $ route ->getPath (), $ options [ ' container ' ] ?? null ),
65
65
];
66
66
67
67
if ($ showControllers ) {
68
- $ row [] = $ controller ? $ this ->formatControllerLink ($ controller , $ this ->formatCallable ($ controller )) : '' ;
68
+ $ row [] = $ controller ? $ this ->formatControllerLink ($ controller , $ this ->formatCallable ($ controller ), $ options [ ' container ' ] ?? null ) : '' ;
69
69
}
70
70
71
71
$ tableRows [] = $ row ;
@@ -84,7 +84,7 @@ protected function describeRoute(Route $route, array $options = [])
84
84
{
85
85
$ defaults = $ route ->getDefaults ();
86
86
if (isset ($ defaults ['_controller ' ])) {
87
- $ defaults ['_controller ' ] = $ this ->formatControllerLink ($ defaults ['_controller ' ], $ this ->formatCallable ($ defaults ['_controller ' ]));
87
+ $ defaults ['_controller ' ] = $ this ->formatControllerLink ($ defaults ['_controller ' ], $ this ->formatCallable ($ defaults ['_controller ' ]), $ options [ ' container ' ] ?? null );
88
88
}
89
89
90
90
$ tableHeaders = ['Property ' , 'Value ' ];
@@ -528,7 +528,7 @@ private function formatRouterConfig(array $config): string
528
528
return trim ($ configAsString );
529
529
}
530
530
531
- private function formatControllerLink ($ controller , string $ anchorText ): string
531
+ private function formatControllerLink ($ controller , string $ anchorText, callable $ getContainer = null ): string
532
532
{
533
533
if (null === $ this ->fileLinkFormatter ) {
534
534
return $ anchorText ;
@@ -549,7 +549,23 @@ private function formatControllerLink($controller, string $anchorText): string
549
549
$ r = new \ReflectionFunction ($ controller );
550
550
}
551
551
} catch (\ReflectionException $ e ) {
552
- return $ anchorText ;
552
+ $ id = $ controller ;
553
+ $ method = '__invoke ' ;
554
+
555
+ if ($ pos = strpos ($ controller , ':: ' )) {
556
+ $ id = substr ($ controller , 0 , $ pos );
557
+ $ method = substr ($ controller , $ pos + 2 );
558
+ }
559
+
560
+ if (!$ getContainer || !($ container = $ getContainer ()) || !$ container ->has ($ id )) {
561
+ return $ anchorText ;
562
+ }
563
+
564
+ try {
565
+ $ r = new \ReflectionMethod ($ container ->findDefinition ($ id )->getClass (), $ method );
566
+ } catch (\ReflectionException $ e ) {
567
+ return $ anchorText ;
568
+ }
553
569
}
554
570
555
571
$ fileLink = $ this ->fileLinkFormatter ->format ($ r ->getFileName (), $ r ->getStartLine ());
0 commit comments