0

問題

メソッドのカスタム動作のために、Zend_View_Helper_Navigation_Menuを拡張する必要があります。あなたが知ることが重要な場合、私はモジュールを使用します。

いくつかの解決策

私の問題

私はすべてのソリューションとそれらの組み合わせを実装しましたが、それでも失敗に終わります...みんな、私は何かヒントを待っています。

編集:問題は何も起こらないということです。標準のヘルパーが使用されます(これは正常に機能します)。

私のコード

私のBootstrap.phpファイル:

protected function _initNavigation() {
    $this->bootstrap('view');
    $view = $this->getResource('view');

    $view->addHelperPath('/../library/Application/View/Helper/Navigation', 'Application_View_Helper_');     
    $view->navigation($this->doGetNavigation());
}

Application_View_Helper_Navigation_Menuのクラス(ROOT / library / Application / View / Helper / Navigation):

class Application_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    public function menu(Zend_Navigation_Container $container = null)
    {
        echo 'Application_View_Helper_Navigation_Menu::menu(...)';
        return parent::menu($container);
    }
}

Zend_Debug::dump($this->getHelperPaths())の見解:

array (size=3)
    'Zend_View_Helper_' =>
array (size=1)
    0 => string 'Zend/View/Helper/' (length=17)
    'Application_View_Helper_' =>
array (size=1)
    0 => string '/../library/Application/View/Helper/Navigation/' (length=47)
    'Fleet_View_Helper_' =>
array (size=1)
    0 => string 'C:/repos/statistics/trunk/application/modules/fleet/views\helpers/' (length=70)

私のスクリプトビュー:

echo $this->navigation()->menu();
4

1 に答える 1

0

application.ini にある

resources.view.helperPath.Test_View_Helper_ = APPLICATION_PATH "/views/helpers"
resources.view.helperPath.Test_View_Helper_Navigation = APPLICATION_PATH "/views/helpers/Navigation"

次に、application/views/helpers/Navigation.php で

class Test_View_Helper_Navigation extends Zend_View_Helper_Navigation
{
    public function navigation(Zend_Navigation_Container $container = null)
    {
         $this->view->getHelper ('Menu');
         $this->_helper ['menu'] = new Test_View_Helper_Navigation_Menu();
     return parent::navigation($container);
    }
}

application/views/helpers/Navigation/Menu.php 内

class Test_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    public function render(Zend_Navigation_Container $container = null)
    {
        return 'It is I.';
    }
}
于 2012-10-23T20:03:44.590 に答える