Sorry forgot to put $viewRenderer into the preDispatch function.
=======================================================
As far as I know, a plugin is not View aware.
You can that functionality by:
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
So your plugin could be like this:
class AuthPlugin extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract
$request) {
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$viewRenderer->view->user = $auth->getIdentity();
}
}
}
Cheers,
Holger
-----Original Message-----
From: Denis Fohl [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 15, 2008 5:21 PM
To: [email protected]
Subject: [fw-general] interaction between controller plugin and front
controller or view
Hi all,
i'm learning with zend framework and mvc architecture... and it's hard
for me :-)
Beause i want it for each controller in my app i made a plugin wich
purpose is to test if user is authenticated. I would like it, if true,
to pass the info to the view but it does not work, even i user is
authenticated, my view var is null. I suppose it's because the view
objetc is not yet initialised when the plugin is executed but i can't
see where or when to do this.
Here is my plugin :
class AuthPlugin extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract
$request) {
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->view->user = $auth->getIdentity();
}
}
}
thanks for help
--
Denis