@@ -49,6 +49,7 @@ public function link(string $dest, array $params = []): string
4949 if (!preg_match ('~^([\w:]+):(\w*+)(#.*)?()$~D ' , $ dest , $ m )) {
5050 throw new UI \InvalidLinkException ("Invalid link destination ' $ dest'. " );
5151 }
52+
5253 [, $ presenter , $ action , $ frag ] = $ m ;
5354
5455 try {
@@ -63,6 +64,7 @@ public function link(string $dest, array $params = []): string
6364 if ($ action === '' ) {
6465 $ action = UI \Presenter::DEFAULT_ACTION ;
6566 }
67+
6668 if (
6769 method_exists ($ class , $ method = $ class ::formatActionMethod ($ action ))
6870 || method_exists ($ class , $ method = $ class ::formatRenderMethod ($ action ))
@@ -72,7 +74,6 @@ public function link(string $dest, array $params = []): string
7274 $ rp = $ missing [0 ];
7375 throw new UI \InvalidLinkException ("Missing parameter \${$ rp ->getName ()} required by {$ rp ->getDeclaringClass ()->getName ()}:: {$ rp ->getDeclaringFunction ()->getName ()}() " );
7476 }
75-
7677 } elseif (array_key_exists (0 , $ params )) {
7778 throw new UI \InvalidLinkException ("Unable to pass parameters to action ' $ presenter: $ action', missing corresponding method. " );
7879 }
@@ -81,6 +82,7 @@ public function link(string $dest, array $params = []): string
8182 if ($ action !== '' ) {
8283 $ params [UI \Presenter::ACTION_KEY ] = $ action ;
8384 }
85+
8486 $ params [UI \Presenter::PRESENTER_KEY ] = $ presenter ;
8587
8688 $ url = $ this ->router ->constructUrl ($ params , $ this ->refUrl );
@@ -89,6 +91,7 @@ public function link(string $dest, array $params = []): string
8991 $ paramsDecoded = urldecode (http_build_query ($ params , '' , ', ' ));
9092 throw new UI \InvalidLinkException ("No route for $ dest( $ paramsDecoded) " );
9193 }
94+
9295 return $ url . $ frag ;
9396 }
9497
0 commit comments