如何从 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();