TL;DR: In ZF1, after registering a custom prefix in application.ini, the Zend_View_Helper_* namespace takes precedence over my own despite working correctly in regular views.
- Created an override of
Zend_View_Helper_Url
, calledApp_View_Helper_Url
. - Placed the file in
APPPLICATION_PATH/library/App/View/Helper/Url.php
- Registered the namespace via application.ini:
resources.view.helperPath.App_View_Helper = APPLICATION_PATH "/library/App/View/Helper"
This works. In my Views, the custom URL helper is now being called. However, in template views, the additional namespace doesn't seem to take hold. I verified this by running this snippet: <?php var_dump(get_class($this->getHelper('url'))); ?>
- index.phtml:
App_View_Helper_Url
- layout.phtml:
Zend_View_Helper_Url
I've tried resolving this by explicitly setting the Layout view to the View resource being bootstrapped - this did not work.
$this->getResource('layout')->setView($this->getResource('view'));
In the end I fixed it by fixing doing the following in the Bootstrap:
$view = $layout->getView();
$view->addHelperPath(APPLICATION_PATH . '/library/App/View/Helper', 'App_View_Helper');
This solution is not very satisfying as I'm now defining the same helper path twice, leading to potential breakage down the line. So while I have a workaround, I'd prefer to understand how/where to configure the Zend_View instance used by Zend_Layout correctly, preferably through application.ini.