|
This post has NOT been accepted by the mailing list yet.
Hi ZF2 Geeks,
I've some trouble with creating a navigation in ZF2. My configuration is very simple: <?php return array( 'home' => array( 'label' => 'Home', 'controller' => 'index', 'action' => 'index' ) ); The initialize method which is called by Module.php: $data = require_once realpath(__DIR__ . '/config/navigation.php'); $navigation = new Config($data); $view->plugin('navigation')->setContainer(new Navigation($navigation)); After that my application throws an exception: Fatal error: Uncaught exception 'Zend\Navigation\Exception\DomainException' with message 'Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\View\Helper\Url instance is composed' in /library/Zend/Navigation/Page/Mvc.php:171 Stack trace: #0 /library/Zend/View/Helper/Navigation/Menu.php(239): Zend\Navigation\Page\Mvc->getHref() #1 /library/Zend/View/Helper/Navigation/Menu.php(453): Zend\View\Helper\Navigation\Menu->htmlify(Object(Zend\Navigation\Page\Mvc)) #2 /library/Zend/View/Helper/Navigation/Menu.php(511): Zend\View\Helper\Navigation\Menu->_renderMenu(Object(Zend\Navigation\Navigation), 'navigation', '', 0, NULL, false) #3 /library/Zend/View/Helper/Navigation/Menu.php(648): Zend\View\Helper\Navigation\Menu->renderMenu(NULL) #4 /library/Zend/View/Helper/Navigation.php(372): Zend\View\Help in /library/Zend/Navigation/Page/Mvc.php on line 171 But I don't know why there is a problem and how I can fix it. Greets, Marc |
|
Same here.
It's necessary to set the helper and routematch manually in MVC. So the provided example at http://packages.zendframework.com/docs/latest/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation can not work. Maybe there is an undocumented requirement so the objects will be injected somehow. The documentation needs to be reviewed anyway. There are a lot of false example, hints, descriptions etc.! |
|
Am Donnerstag, den 12.04.2012, 07:25 +0200 schrieb dershao
<[hidden email]>: > Same here. > It's necessary to set the helper and routematch manually in MVC. > So the provided example at > > http://packages.zendframework.com/docs/latest/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation > can not work. > > Maybe there is an undocumented requirement so the objects will be > injected > somehow. Work in progress: https://github.com/zendframework/zf2/pull/952 > The documentation needs to be reviewed anyway. > There are a lot of false example, hints, descriptions etc.! Update the docs before features are implemented and components refactored? You work with a beta version! > -- > View this message in context: > > http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4552041.html > Sent from the Zend Framework mailing list archive at Nabble.com. -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
It looks like the fix was closed/reverted? Is there another way of using controller/action in navigation helper? here is what i'm trying to do: //config/navigation.php <?php return array( array( 'label' => 'Login', 'controller' => 'user', 'action' => 'login', ), ); //Module: public function initializeView($e) { $navigation = include __DIR__ . '/config/navigation.php'; $renderer->plugin('navigation')->setContainer(new Navigation($navigation)); } //layout.phtml: <?php echo $this->navigation()->render(); ?> I get the following error: PHP Fatal error: Uncaught exception 'Zend\Navigation\Exception\DomainException' with message 'Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\View\Helper\Url instance is composed' in /***/Zend/Navigation/Page/Mvc.php:187 Thanks! |
|
Am Dienstag, den 24.04.2012, 07:43 +0200 schrieb cmple
<[hidden email]>: > Frank Brückner wrote >> >> Am Donnerstag, den 12.04.2012, 07:25 +0200 schrieb dershao >> <dershao@>: >>> Same here. >>> It's necessary to set the helper and routematch manually in MVC. >>> So the provided example at >>> >>> >>> http://packages.zendframework.com/docs/latest/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation >>> can not work. >>> >>> Maybe there is an undocumented requirement so the objects will be >>> injected >>> somehow. >> >> Work in progress: https://github.com/zendframework/zf2/pull/952 >> >>> The documentation needs to be reviewed anyway. >>> There are a lot of false example, hints, descriptions etc.! >> >> Update the docs before features are implemented and components >> refactored? >> You work with a beta version! >> >>> -- >>> View this message in context: >>> >>> >>> http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4552041.html >>> Sent from the Zend Framework mailing list archive at Nabble.com. >> >> >> -- >> List: fw-general@.zend >> Info: http://framework.zend.com/archives >> Unsubscribe: fw-general-unsubscribe@.zend >> > It looks like the fix was closed/reverted? > Is there another way of using controller/action in navigation helper? > here is what i'm trying to do: > > //config/navigation.php > <?php > return array( > array( > 'label' => 'Login', > 'controller' => 'user', > 'action' => 'login', > ), > ); > > //Module: > public function initializeView($e) > { > $navigation = include __DIR__ . '/config/navigation.php'; > $renderer->plugin('navigation')->setContainer(new > Navigation($navigation)); > } > > //layout.phtml: > <?php echo $this->navigation()->render(); ?> > > I get the following error: > PHP Fatal error: Uncaught exception > 'Zend\Navigation\Exception\DomainException' with message > 'Zend\Navigation\Page\Mvc::getHref cannot execute as no > Zend\View\Helper\Url > instance is composed' in /***/Zend/Navigation/Page/Mvc.php:187 > > Thanks! You can find an example in the issue tracker. Maybe this is a help. http://framework.zend.com/issues/browse/ZF2-126?focusedCommentId=49991&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-49991 > -- > View this message in context: > > http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4583711.html > Sent from the Zend Framework mailing list archive at Nabble.com. -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
Got it, Thanks Frank! It looks like it's way back from 2011, Any Idea when this will be fixed/pushed? |
|
Am Dienstag, den 24.04.2012, 09:03 +0200 schrieb cmple
<[hidden email]>: > Frank Brückner wrote >> >> Am Dienstag, den 24.04.2012, 07:43 +0200 schrieb cmple >> <roman.vidyayev@>: >>> Frank Brückner wrote >>>> >>>> Am Donnerstag, den 12.04.2012, 07:25 +0200 schrieb dershao >>>> <dershao@>: >>>>> Same here. >>>>> It's necessary to set the helper and routematch manually in MVC. >>>>> So the provided example at >>>>> >>>>> >>>>> >>>>> http://packages.zendframework.com/docs/latest/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation >>>>> can not work. >>>>> >>>>> Maybe there is an undocumented requirement so the objects will be >>>>> injected >>>>> somehow. >>>> >>>> Work in progress: https://github.com/zendframework/zf2/pull/952 >>>> >>>>> The documentation needs to be reviewed anyway. >>>>> There are a lot of false example, hints, descriptions etc.! >>>> >>>> Update the docs before features are implemented and components >>>> refactored? >>>> You work with a beta version! >>>> >>>>> -- >>>>> View this message in context: >>>>> >>>>> >>>>> >>>>> http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4552041.html >>>>> Sent from the Zend Framework mailing list archive at Nabble.com. >>>> >>>> >>>> -- >>>> List: fw-general@.zend >>>> Info: http://framework.zend.com/archives >>>> Unsubscribe: fw-general-unsubscribe@.zend >>>> >>> It looks like the fix was closed/reverted? >>> Is there another way of using controller/action in navigation >>> helper? >>> here is what i'm trying to do: >>> >>> //config/navigation.php >>> <?php >>> return array( >>> array( >>> 'label' => 'Login', >>> 'controller' => 'user', >>> 'action' => 'login', >>> ), >>> ); >>> >>> //Module: >>> public function initializeView($e) >>> { >>> $navigation = include __DIR__ . '/config/navigation.php'; >>> $renderer->plugin('navigation')->setContainer(new >>> Navigation($navigation)); >>> } >>> >>> //layout.phtml: >>> <?php echo $this->navigation()->render(); ?> >>> >>> I get the following error: >>> PHP Fatal error: Uncaught exception >>> 'Zend\Navigation\Exception\DomainException' with message >>> 'Zend\Navigation\Page\Mvc::getHref cannot execute as no >>> Zend\View\Helper\Url >>> instance is composed' in /***/Zend/Navigation/Page/Mvc.php:187 >>> >>> Thanks! >> >> You can find an example in the issue tracker. Maybe this is a help. >> >> >> >> http://framework.zend.com/issues/browse/ZF2-126?focusedCommentId=49991&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-49991 >> >>> -- >>> View this message in context: >>> >>> >>> http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4583711.html >>> Sent from the Zend Framework mailing list archive at Nabble.com. >> >> >> -- >> List: fw-general@.zend >> Info: http://framework.zend.com/archives >> Unsubscribe: fw-general-unsubscribe@.zend >> > Got it, Thanks Frank! > It looks like it's way back from 2011, Any Idea when this will be > fixed/pushed? Check the unit test and you will see: Tests passed. > -- > View this message in context: > > http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4583993.html > Sent from the Zend Framework mailing list archive at Nabble.com. -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
|
This post was updated on .
I think we are discussing different things here:
Frank is absolutely right: The navigation works fine in the unit tests. But cmple and I are trying to use this component in a view template to generate links. The difference are the following lines: 1. $urlHelper->setRouter($router); 2. $urlHelper->setRouteMatch($routeMatch); 3. \Zend\Navigation\Page\Mvc::setDefaultUrlHelper($urlHelper); In the unit test this dependencies are set explicitly which is not the case in a "real" MVC environment. 1. This could be done in the module class, like Mathew showed recently in his slides: http://mwop.net/slides/2012-04-25-ViewWebinar/Zf2Views.html#slide41 The router is atm not set in the Skeleton Application. 2. This is discussed here: https://github.com/zendframework/zf2/pull/952 Short Summary: routeMatch needs to be injected and beause it's calculated it should not be done via DI but with a locator. The locator is currently in RFC status and heavily discussed. If its available in can be injected manually or via listener (as proposed). 3. Should be set up somewhere like 1. Currently not part of MVC bootstrap but should be easy to implement on yourself. |
|
Am 27.04.2012, 09:39 Uhr, schrieb dershao <[hidden email]>:
> I think we are discussing different things here: > > Frank is absolutely right: The navigation works fine in the unit tests. > But cmple and I are trying to use this component in a view template to > generate links. > > The difference are the following lines: > 1. $urlHelper->setRouter($router); > 2. $urlHelper->setRouteMatch($routeMatch); > 3. \Zend\Navigation\Page\Mvc::setDefaultUrlHelper($urlHelper); > > In the unit test this dependecies are set explicetly which is not the > case > in a "real" MVC environment. > > 1. This could be done in the module class, like Mathew showed recently in > his slides: > http://mwop.net/slides/2012-04-25-ViewWebinar/Zf2Views.html#slide41 > The router is atm not set in the Skeleton Application. > > 2. This is discussed here: > https://github.com/zendframework/zf2/pull/952 > Short Summary: routeMatch needs to be injected and beause it's > calculated it > should not be done via DI but with a locator. The locator is currently in > RFC status and heavily discussed. If its available in can be injected > manually or via listener (as proposed). > > 3. Should be set up somewhere like 1. Currently not part of MVC bootstrap > but should be easy to implement on yourself. > > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-problem-tp4256771p4591984.html > Sent from the Zend Framework mailing list archive at Nabble.com. Right! This all is work in progress. A simple solution will coming. -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
| Powered by Nabble | Edit this page |
