i have class Plugin_Magazine extends Zend_Controller_Action
in some views i need to call static function test()
from it.
in view i do folowing:
$class_name = 'Plugin_'.$plugin;
$class_name::test();
as a result i have
Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given
but, if i create class Plugin_Magazine
w\\o extends all works fine.
question is: can i somehow do what i need or just forget about inheritance?
You need to pass a Request object to the constructor of the Action class
At somepint your doing this:
$pm = new Plugin_Magazine();
But you need to pass the request object:
$pm = new Plugin_Magazine($this->getRequest());
As for this call:
$class_name = 'Plugin_'.$plugin;
$class_name::test();
Why do you need a static function in an Action? This doesn't seem right, if it's reusable logic that exists in an Action that it should be moved elsewhere to where it can be used more easily, like into a Model.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.