如何在控制器中调用静态视图辅助方法?

时间:2013-11-20 12:32:28

标签: zend-framework zend-view zend-controller

就像在主题中一样,我在视图帮助器中有两个静态方法,但是当我尝试通过

调用控制器操作时
Zend_View_Helper_SomeHelper::firstStaticMethod();

我收到了错误:

Warning: include_once(Zend/View/Helper/SomeHelper.php): failed to open stream: No such file or directory in /library/Zend/Loader.php on line 134 Warning: include_once(): Failed opening 'Zend/View/Helper/SomeHelper.php' for inclusion (include_path='/application/../library:/library:.:/usr/share/pear:/usr/share/php') in /library/Zend/Loader.php on line 134 Fatal error: Class 'Zend_View_Helper_SomeHelper' not found in /application/modules/default/controllers/Controller.php on line 174

帮助程序代码:

class Zend_View_Helper_SomeHelper extends Zend_View_Helper_Abstract {
    //....//
    public static function firstStaticMethod(){
        //some code hear
    }
    public static function secoundStaticMethod(){
        //some code hear
    }
}

我需要在帮助器和操作中使用此方法。 任何想法?

1 个答案:

答案 0 :(得分:1)

你能试试吗

$viewHelperObj = $this->view->getHelper('SomeHelper');
$viewHelperObj->secoundStaticMethod();