我想知道如何(如果可能)访问 Zend Framework 应用程序的 Bootstrap.php 文件中 _init 方法的返回值?
最佳答案
Bootstrap.php 中 _init 方法的每个返回值都作为资源受到威胁,因此保存在 bootstrap 的 Zend_Registry 容器中。因此你可以这样做:
// in Bootstrap.php
protected function _initTest() {
return 'some return value';
}
在 Controller 中的某些操作中:
$theTestResource = $this->getInvokeArg('bootstrap')->getResource('test');
// OR you can also do the same as
$theTestResource = $this->getInvokeArg('bootstrap')->getContainer()->test;
关于php - 从 Zend Framework 应用程序中的 Bootstrap.php 获取返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5126931/