如何从Zend中的模型调用bootstrap内部的函数


How to call a function inside the bootstrap from a model in Zend?

我在Bootstrap.php上有一个函数,如:

function test() {
    echo "hello";
}

我想从模型中调用它。我已经知道我可以使用$this->getFrontController()->getParam('bootstrap')->test();从控制器做到这一点,但不知道如何从模型做到这一点。任何帮助吗?

我知道在Bootstrap上有这个函数不是最好的,在其他地方会更好,但这不能发生

您可以使用zend.controller.front.methods.primary.getinstance

从应用程序中的任何地方获取Front Controller
$front = Zend_Controller_Front::getInstance();  

所以我认为这将给出结果

$front = Zend_Controller_Front::getInstance();  
$front->getParam('bootstrap')->test();