Zend Framework中如何在Module Bootstrap中取得View资源对象

本文解决在Zend Framework中ModuleBootstrap尝试获取视图资源时出现的问题。通过正确的引导过程和资源获取方式,确保应用程序正常运行。

      在尝试Zend Framework的Module Bootstrap时,视图获取View资源对象,但是使用类似下面的代码时,

产生错误:

        $this->bootstrap('view');
        $view = $this->getResource('view'); 

       错误信息类似于这个帖子中提问者遇到的:

      Accessing View object from Module Bootstrap

      错误信息类似于:

      Zend_Application_Bootstrap_Exception: Resource matching "view" not found in ....../library/Zend/Application/Bootstrap/BootstrapAbstract.php

 

      根据同贴中的答复者weierophinney的回复,正确的方法应该如同下面的代码:

        $bootstrap = $this->getApplication();
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View'); 

       其更多答复做一个截取转贴于下:

When in a module bootstrap, you need to grab it from the application
bootstrap, which, cryptically, you retrieve with the getApplication()
method

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值