Open
Description
This PR will change 2 things:
-
Add a comment to the HelperPluginManager that the "url" and "basePath" View-Helper factories are overwritten in the
ViewHelperManagerFactory
of zend-mvc. -
Change the exception text of the "url" View-helper if the router cant assemble the URL to include more information:
Before:
Zend\Router\Exception\InvalidArgumentException: Missing parameter "my-parameter" in /var/www/vendor/zendframework/zend-router/src/Http/Segment.php:309
Stack trace:
#0 /var/www/vendor/zendframework/zend-router/src/Http/Segment.php(419): Zend\Router\Http\Segment->buildPath(Array, Array, false, false, Array)
#1 /var/www/vendor/zendframework/zend-router/src/Http/TreeRouteStack.php(370): Zend\Router\Http\Segment->assemble(Array, Array)
#2 /var/www/vendor/zendframework/zend-router/src/Http/Part.php(216): Zend\Router\Http\TreeRouteStack->assemble(Array, Array)
#3 /var/www/vendor/zendframework/zend-router/src/Http/TreeRouteStack.php(370): Zend\Router\Http\Part->assemble(Array, Array)
#4 /var/www/vendor/zendframework/zend-router/src/Http/Part.php(216): Zend\Router\Http\TreeRouteStack->assemble(Array, Array)
#5 /var/www/vendor/zendframework/zend-router/src/Http/TreeRouteStack.php(370): Zend\Router\Http\Part->assemble(Array, Array)
#6 /var/www/vendor/zendframework/zend-router/src/Http/Part.php(216): Zend\Router\Http\TreeRouteStack->assemble(Array, Array)
#7 /var/www/vendor/zendframework/zend-router/src/Http/TreeRouteStack.php(391): Zend\Router\Http\Part->assemble(Array, Array)
#8 /var/www/vendor/zendframework/zend-mvc-i18n/src/Router/TranslatorAwareTreeRouteStack.php(111): Zend\Router\Http\TreeRouteStack->assemble(Array, Array)
#9 /var/www/vendor/zendframework/zend-view/src/Helper/Url.php(106): Zend\Mvc\I18n\Router\TranslatorAwareTreeRouteStack->assemble(Array, Array)
#10 [internal function]: Zend\View\Helper\Url->__invoke('my/route/...', Array, Array, false)
#11 /var/www/vendor/zendframework/zend-view/src/Renderer/PhpRenderer.php(397): call_user_func_array(Object(Zend\View\Helper\Url), Array)
#12 /var/www/module/xxx/view/xxx/yyy.phtml(101): Zend\View\Renderer\PhpRenderer->__call('url', Array)
...
After:
Zend\View\Helper\Exception\InvalidArgumentException: Couldnt create URL for route "my/route/do-it", params "{}" and options "[]" in /var/www/vendor/zendframework/zend-view/src/Helper/Url.php:109
Stack trace:
#0 [internal function]: Zend\View\Helper\Url->__invoke('my/route/...', Array)
#1 /var/www/vendor/zendframework/zend-view/src/Renderer/PhpRenderer.php(397): call_user_func_array(Object(Zend\View\Helper\Url), Array)
#2 /var/www/module/xxx/view/xxx/yyy.phtml(101): Zend\View\Renderer\PhpRenderer->__call('url', Array)
...
Advantages:
- full route name clearly visible
- full parameters list clearly visible
- the calling view-script is way higher in the stack trace and therefore easier to find (see place 2 vs 12)
Open questions:
- Use json_encode? We'd have to add ext-json to the
composer.json
...
Originally posted by @MatthiasKuehneEllerhold at zendframework/zend-view#200
Activity