php - 从 Zend Framework 应用程序中的 Bootstrap.php 获取返回值

标签 php zend-framework

我想知道如何(如果可能)访问 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/

相关文章:

php - 定制 CMS 还是第三方?

zend-framework - Zend Framework 1.10中Captcha元素的自定义错误消息

php - 如何触发MySQL查询

php - Wordpress 自定义帖子类型列排序查询

php - 为什么 (My)SQL 中的 Sum() 函数返回的值是我期望的值的两倍?

php - 通过 PHP 编码执行 Linux-CentOS 命令行

php - MYSQL - 加入或子查询问题

ajax - Zend Framework::Ajax 请求

zend-framework - 如何从 Doctic 2.0 和 Zend 框架中的 Controller 访问自定义存储库?

zend-framework - 预填充密码字段 zend 框架