dtlygweb2017 2011-01-31 15:46
浏览 16

Zend_View和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 two, 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 )

  • 写回答

1条回答 默认 最新

  • dongzhang1864 2011-01-31 16:32
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line