$this->getInvokeArg('bootstrap')->getOptio

2019-06-12 07:32发布

using ... $this->getInvokeArg('bootstrap')->getOptions(); .. to retrieve my config settings from application.ini (using Zend Framework 1.11). this is failing when called from a Zend Helper file but works when called in a controller

why?

1条回答
闹够了就滚
2楼-- · 2019-06-12 08:09

The getInvokeArg() method exists for controllers (classes extending Zend_Controller_Action), but is not available for action helpers (classes extending Zend_Controller_Action_Helper_Abstract - I suppose that is what you mean with "Zend Helper file"). You can confirm this in the Zend Framework API, which is a very useful reference when developing with the Zend Framework.

To call getInvokeArg() within an action helper, you must first get the current action controller, which you can do within action helpers by calling the getActionController() method. Concluding, within an action helper, the following code will do what you want:

$this->getActionController()->getInvokeArg('bootstrap')->getOptions();

The $this keyword refers to the current class; as such, within an action helper, $this refers to the action helper, and not the controller.

查看更多
登录 后发表回答