He creado el Plugin:
Código PHP:
<?php
require_once 'Zend/Controller/Plugin/Abstract.php';
class LoginPlugin extends Zend_Controller_Plugin_Abstract {
protected $_stack;
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$stack = $this->getStack();
$menuRequest = new Zend_Controller_Request_Simple();
$menuRequest->setControllerName('login')
->setActionName('index');
$stack->pushStack($menuRequest);
}
public function getStack()
{
if (null === $this->_stack) {
$front = Zend_Controller_Front::getInstance();
if (!$front->hasPlugin('Zend_Controller_Plugin_ActionStack')) {
$stack = new Zend_Controller_Plugin_ActionStack();
$front->registerPlugin($stack);
} else {
$stack = $front->getPlugin('ActionStack');
}
$this->_stack = $stack;
}
return $this->_stack;
}
}
Cita:
El Plugin lo he guardado en la misma carpeta que el controlador LoginController.phpFatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (login)'
Posteriormente lo he registrado:
Código PHP:
$frontController = Zend_Controller_Front::getInstance();
$frontController->addModuleDirectory(self::getBaseDir() . '/application/modules')
->registerPlugin(new LoginPlugin())
->throwExceptions(true)
->dispatch();
Gracias
Un saludo