Перенаправление URL-адреса Zend Framework

<?php class PI_Controller_Plugin_AssetGrabber extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { /* The module name */ $moduleName = $request->getModuleName(); /* This modules requires the user to be loggedin in order to see the web pages! */ $loginRequiredModules = array('admin'); if (in_array($moduleName,$loginRequiredModules)) { $adminLogin = new Zend_Session_Namespace('adminLogin'); if (!isset($adminLogin->loggedin)) { /*-------------------------------------- Here I want to redirect the user */ $this->_redirect('/something'); } } } } 

Я пытаюсь сделать перенаправление $this->_redirect('/something') но не работает! Вы знаете, как я могу сделать переадресацию в этом случае?

С наилучшими пожеланиями,

Либо используйте Zend_Controller_Action_HelperBroker чтобы получить помощник перенаправления или перенаправить непосредственно из объекта Request.

См. Примеры, приведенные в

  • Перенаправление в плагин Front Controller Zend

… остальная часть кода

 if (!isset($adminLogin->loggedin)) { $baseUrl = new Zend_View_Helper_BaseUrl(); $this->getResponse()->setRedirect($baseUrl->baseUrl().'/something'); } - if (!isset($adminLogin->loggedin)) { $baseUrl = new Zend_View_Helper_BaseUrl(); $this->getResponse()->setRedirect($baseUrl->baseUrl().'/something'); } 

… остальная часть кода

 <?php class AlternativeController extends Zend_Controller_Action { /** * Redirector - defined for code completion * * @var Zend_Controller_Action_Helper_Redirector */ protected $_redirector = null; public function init() { $this->_redirector = $this->_helper->getHelper('Redirector'); } public function myAction() { /* Some Awesome Code */ $this->redirector('targetAction', 'targetController'); return; //Never reached! } } 

Вам нужно получить помощник redirector, затем вы можете определить targetAction и targetController с перенаправителем. Это должно сделать это.