@@ -57,7 +57,7 @@ public function __construct(
5757 */
5858 public function getTab (): string
5959 {
60- $ this ->analyse ($ this ->router );
60+ $ this ->analyse ($ this ->router , $ this -> httpRequest );
6161 return Nette \Utils \Helpers::capture (function () {
6262 $ matched = $ this ->matched ;
6363 require __DIR__ . '/templates/RoutingPanel.tab.phtml ' ;
@@ -87,21 +87,33 @@ public function getPanel(): string
8787 */
8888 private function analyse (
8989 Routing \Router $ router ,
90+ Nette \Http \IRequest $ httpRequest ,
9091 string $ module = '' ,
92+ string $ path = null ,
9193 bool $ parentMatches = true ,
9294 int $ level = -1 ,
9395 int $ flag = 0
9496 ): void {
9597 if ($ router instanceof Routing \RouteList) {
9698 try {
97- $ parentMatches = $ parentMatches && $ router ->match ($ this -> httpRequest ) !== null ;
99+ $ parentMatches = $ parentMatches && $ router ->match ($ httpRequest ) !== null ;
98100 } catch (\Throwable $ e ) {
99101 }
102+
103+ $ prop = (new \ReflectionProperty (Routing \RouteList::class, 'path ' ));
104+ $ prop ->setAccessible (true );
105+ if ($ pathPrefix = $ prop ->getValue ($ router )) {
106+ $ path .= $ pathPrefix ;
107+ $ url = $ httpRequest ->getUrl ();
108+ $ httpRequest = $ httpRequest ->withUrl ($ url ->withPath ($ url ->getPath (), $ url ->getBasePath () . $ pathPrefix ));
109+ }
110+
111+ $ module .= ($ router instanceof Nette \Application \Routers \RouteList ? $ router ->getModule () : '' );
112+
100113 $ next = count ($ this ->routers );
101- $ parentModule = $ module . ($ router instanceof Nette \Application \Routers \RouteList ? $ router ->getModule () : '' );
102114 $ flags = $ router ->getFlags ();
103115 foreach ($ router ->getRouters () as $ i => $ subRouter ) {
104- $ this ->analyse ($ subRouter , $ parentModule , $ parentMatches , $ level + 1 , $ flags [$ i ]);
116+ $ this ->analyse ($ subRouter , $ httpRequest , $ module , $ path , $ parentMatches , $ level + 1 , $ flags [$ i ]);
105117 }
106118
107119 if ($ info = $ this ->routers [$ next ] ?? null ) {
@@ -117,7 +129,7 @@ private function analyse(
117129 $ params = $ e = null ;
118130 try {
119131 $ params = $ parentMatches
120- ? $ router ->match ($ this -> httpRequest )
132+ ? $ router ->match ($ httpRequest )
121133 : null ;
122134 } catch (\Throwable $ e ) {
123135 $ matched = 'error ' ;
@@ -142,6 +154,7 @@ private function analyse(
142154 'mask ' => $ router instanceof Routing \Route ? $ router ->getMask () : null ,
143155 'params ' => $ params ,
144156 'module ' => rtrim ($ module , ': ' ),
157+ 'path ' => $ path ,
145158 'error ' => $ e ,
146159 ];
147160 }
0 commit comments