Zend redirection what's the difference between the two ways

Is there any real difference between

$this->_redirect('controller/action');

and

$request->setControllerName('controller')
        ->setActionName('action');

I guess the first may use the second behind the curtains. Somebody knows?

+3
source share
3 answers

Redirector URL-. _redirect() , sitewide gotoSimple ($ action, $controller, $module, $params) , Zend_Controller_Action:: _ ().

setController() setAction() , URL- ( 302), . , , _redirect() redirecotor, , . : http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#Redirector

$this → _ forward() , setController() setAction(), Zend_Controller_Action:

final protected function _forward($action, $controller = null, $module = null, array $params = null)
{
    $request = $this->getRequest();

    if (null !== $params) {
        $request->setParams($params);
    }

    if (null !== $controller) {
        $request->setControllerName($controller);

        // Module should only be reset if controller has been specified
        if (null !== $module) {
            $request->setModuleName($module);
        }
    }

    $request->setActionName($action)
            ->setDispatched(false);
}

Zend_Controller_Action, , Zend_Controller_Plugin, , .

, , pratice , , .

:

http://framework.zend.com/manual/en/zend.controller.dispatcher.html

http://devzone.zend.com/article/11978

+4

, Redirector HTTP, , ( , ), , , .

, , HTTP- ( , ), - , ( , ).

+4

The first is a physical redirect by sending 302 headers. The second option is more like what _forward () does - change the name and action of the controller for the current request.

+2
source

Source: https://habr.com/ru/post/1771719/


All Articles