zend action helpres 使用控制器所需的解释
有人可以告诉我 zend action helpers 到底是如何工作的吗?我的意思是,尽管我已经在我的代码中使用了它们,但我觉得我的理解中缺少一些东西:
例如,我的代码中有这样的东西
$this->_helper->viewRenderer->setRender('edit',null,true);
,所以我会能够渲染添加操作以使用编辑页面(因为添加与编辑相同......至少在 UI 基础上),
但我的问题是,据我所知 _helper 是一个实例,
/**
* Helper Broker to assist in routing help requests to the proper object
*
* @var Zend_Controller_Action_HelperBroker
*/
protected $_helper = null;
但是当我尝试在库文件夹中查看此类“Zend_Controller_Action_HelperBroker”,我找不到名为“viewRenderer”的属性
can some one tell me how zend action helpers exactly work , i mean , even though i already used them in my code i feel some thing is missing in my understanding :
e.g. i have some thing like this
$this->_helper->viewRenderer->setRender('edit',null,true);
i my code , so that i will be able to render add-actions to use edit pages (since adding is the same as editing ..... on UI basis @ least )
but my question here is , as far as i can see the _helper is an instance of
/**
* Helper Broker to assist in routing help requests to the proper object
*
* @var Zend_Controller_Action_HelperBroker
*/
protected $_helper = null;
but when i try to see in the library folder this class "Zend_Controller_Action_HelperBroker" i can't find a property named "viewRenderer"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$_helper
是一个神奇的小东西,可以在需要时加载操作助手。它会在注册路径中查找 - 默认情况下是Zend/Controller/Action/Helper
- 您可以在其中找到viewRenderer
帮助器。该类没有
viewRenderer
属性的事实是因为 HelperBroker 通过神奇的__call
方法处理所有请求。此调用方法查找助手(在本例中为 viewRenderer)并调用该助手上的
direct()
方法。The
$_helper
is a magical little thing that loads action helpers when needed. It looks in registered paths - which by default isZend/Controller/Action/Helper
- which is where you'll find theviewRenderer
helper.The fact that the class doesn't have a
viewRenderer
property is because the HelperBroker handles all requests via the magic__call
method.This call method looks for a helper (in this case viewRenderer) and calls the
direct()
method on that helper.