Zend_View and addHelperPath
I've got a problem using an empty Zend_View and addHelperPath. Someone knows where is the difference between
$view = Zend_Layout::getMvcInstance()->getView();
$view->addHelperPath(
APPLICATION_PATH . '/views/helpers/layouts',
'FOO_View_Helper'
);
and
$view = new Zend_View;
$view->addHelperPath(
APPLICATION_PATH . '/views/helpers/layouts',
'FOO_View_Helper'
);
Zend_Layout::getMvcInstance()->setView($view);
$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$helper->setView($view);
With example number one, my view helper got loaded. Example number two said
Plugin by name 'PriceOutput' was not found in the registry; used paths:
Zend_View_Helper_: Zend/View/Helper/;./views\helpers/
I've added an
echo "<xmp>", var_dump($registry), "</xmp>";
in
PluginLoader::load($name, $throwExceptions = true)
and the helperPaths are all at the same place. But with example Number t开发者_C百科wo, ZF seems to search only in Zend_View_Helper
and not in FOO_View_Helper
.
Any ideas?
Like I told, the first example took a look at FOO_View_Helper, the 2nd not:
Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'FooBar' was not found in the registry; used paths: FOO_View_Helper_: C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/basket/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/globallayer/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/globallayer/help/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/globallayer/styleinfolayer/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/layout/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/nys/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/overview/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/search/;C:\Programme\Zend\Apache2\htdocs\trunk_webshop\application/views/helpers/singleproductview/;C:\Programme\Zend in C:\Programme\Zend\Apache2\htdocs\trunk_core_webshop\library\Zend\Loader\PluginLoader.php on line 414
($view->getHelperPaths() should be better :P )
With this one
$view = Zend_Layout::getMvcInstance()->getView();
$view->addHelperPath(
APPLICATION_PATH . '/views/helpers/layouts',
'FOO_View_Helper'
);
You are getting the existing View and setting the path, this is correct.
But with the second example you are creating a new view and then setting the path, thus replacing the existing View that was automatically (and correctly) loaded by your Bootstrap. This new View has no idea about your Bootstrap and therefore no idea about your autoloader - hence the errors.
精彩评论