ZF-10458: Ability to register custom navigation helpers outside of Zend Library to interact with proxy found in navigation
Description
When Attempting to create a custom navigation view helper I found if difficult to register it with the navigation view helper.
i.e. App_View_Helper_Navigation_Context should be accessible through $this->navigation->context()
In order to provide this functionality I had to subclass the navigation helper but as its quite a straight forward improvement I have included a patch for Zend_View_Helper_Navigation
--- library/Zend/View/Helper/Navigation.php (revision 22945)
+++ library/Zend/View/Helper/Navigation.php (working copy)
@@ -156,10 +156,13 @@
return $this->_helpers[$proxy];
}
- if (!$this->view->getPluginLoader('helper')->getPaths(self::NS)) {
- $this->view->addHelperPath(
- str_replace('_', '/', self::NS),
- self::NS);
+ $paths = $this->view->getPluginLoader('helper')->getPaths();
+ foreach($paths AS $ns => $path) {
+ if (!$this->view->getPluginLoader('helper')->getPaths($ns . 'Navigation_')) {
+ $this->view->addHelperPath(
+ str_replace('_', '/', $ns . 'Navigation_'),
+ $ns . 'Navigation');
+ }
}
if ($strict) {
Comments
Posted by Matt Cockayne (matt.cockayne) on 2010-09-15T06:00:40.000+0000
Patch file for mentioned change
Posted by Frank Brückner (frosch) on 2011-11-05T20:56:32.000+0000
Hi Matt, I see no problem!
Add your path for the helper and the prefix for the class to {{Zend_View}}.
Set view helper path:
And you can use your own navigation helper by proxy: ```
My unit test for this issue runs without any failures.
Posted by Frank Brückner (frosch) on 2011-11-15T21:57:21.000+0000
I found a problem:
A helper with the name "My_View_Helper_Navigation_Menu" can not be used, because the proxy helper returns always the standard view helper "Zend_View_Helper_Navigation_Menu".
Posted by Frank Brückner (frosch) on 2011-11-15T21:59:47.000+0000
Patch and unit tests added.
Posted by Rob Allen (rob) on 2012-06-19T19:00:38.000+0000
tests fail:
Posted by Frank Brückner (frosch) on 2012-06-19T19:59:50.000+0000
Updated unit tests.
Posted by Rob Allen (rob) on 2012-06-19T20:30:55.000+0000
Resolved in svn r24986(trunk) and r24987(release-1.12)
Posted by Cristian Bichis (avantis) on 2012-08-31T16:37:49.000+0000
Hi Rob,
The fix doesn't seems to work on 1.12.0 as far as I see.
Basically I don't need to add another view helper path right? Or should I add:
resources.view.helperPath.My_View_Helper_Navigation = "My/View/Helper/Navigation"
?
Posted by Frank Brückner (frosch) on 2012-09-03T07:36:17.000+0000
@[~avantis]
You must add the helper path! Look at the unit tests for examples.
The problem was: {quote}A helper with the name "My_View_Helper_Navigation_Menu" can not be used, because the proxy helper returns always the standard view helper "Zend_View_Helper_Navigation_Menu".{quote}
If you have more questions please write me an e-mail.