Featured post
Acessing Controller and Action name at _initVars() Zend Framework -
i hope had made me clear in question!
i access getcontrollername() , getactionname() inside _initvars(). i'm trying do:
protected function _initvars() { $this->bootstrap('layout'); $layout = $this->getresource('layout'); $view = $layout->getview(); $view->theme = 'my_theme'; $this->bootstrap('frontcontroller'); $front = $this->getresource('frontcontroller'); echo '<pre>'; print_r($front->getrequest()); echo '</pre>'; exit; return $view; }
i'm getting no response, fields controllername , actionname returning empty, in return:
zend_controller_front object ( [_baseurl:protected] => [_controllerdir:protected] => [_dispatcher:protected] => zend_controller_dispatcher_standard object ( [_curdirectory:protected] => [_curmodule:protected] => default [_controllerdirectory:protected] => array ( [default] => /var/www/proj_rodrigo/application/controllers ) [_defaultaction:protected] => index [_defaultcontroller:protected] => index [_defaultmodule:protected] => default [_frontcontroller:protected] => [_invokeparams:protected] => array ( )
it's part of code, necessary things there, in old schema of zend capable calling zend_front_controller, don't know more how use it.
appreciate help! best regards , sorry bad english.
to fix issue, add postdispatche @ plugin:
public function postdispatch(zend_controller_request_abstract $request) {
$bootstrap = zend_controller_front::getinstance()->getparam('bootstrap'); $layout = $bootstrap->getresource('layout'); $view = $layout->getview(); $view->controller = $this->getrequest()->getcontrollername(); $view->action = $this->getrequest()->getactionname();
}
thanks again!
it looks code in bootstrap
class. since bootstrap
code runs before routing - in, fact stage routing defined - controller , action not yet determined.
if want info, need create front-controller plugin implementing early-running method - runs after routing has set controller , action - routeshutdown()
or dispatchloopstartup()
or predispatch()
.
check out: zf dispatch overview (pdf)
- Get link
- X
- Other Apps
Comments
Post a Comment