I need to create my own resource which sends some information to Zend_View
instance which depends on currently working controller and action.
I've got this code:
$view = $bootstrap->getResource('layout')->getView();
$front = $bootstrap->getResource('frontController');
$front->setRequest(new Zend_Controller_Request_Http);
$controller = $front->getRequest()->getControllerName();
$action = $front->getRequest()->getActionName();
$view->headTitle(
$this->getPage()
->setController($controller)
->setAction($action)
->getTitle()
);
but $controller
and $action
are empty. I don't know if I'm doing something wrong or getting access to controller and action names is impossible in resource.
You can't access the request object in a resource because it doesn't exist yet. The request object gets set during dispatch which happens after the application has been bootstrapped. It sounds like this logic should be moved to a controller plugin instead.