public function redirect($url, $delay = 0, $statusCode = 302) { $actionInstance = $this->context->getActionStack()->getLastEntry()->getActionInstance(); $result = sfView::SUCCESS; if ($this->context->getUser()->hasFlash('error')) { $result = sfView::ERROR; } opExecutionFilter::notifyPostExecuteActionEvent($this, $this->dispatcher, $actionInstance, $result); parent::redirect($url, $delay, $statusCode); }
/** * @see sfWebController */ public function redirect($url, $delay = 0, $statusCode = 302) { $url = $this->genUrl($url, true); if (!$this->context->getRequest()->isCookie()) { $matchd = '/' . preg_quote(session_name(), '/') . '=.*([&|#]?)/'; if (preg_match($matchd, $url)) { $url = preg_replace($matchd, SID . '\\1', $url); } else { if (strpos($url, '?') !== false) { $url .= '&'; } else { $url .= '?'; } $url .= SID; } } parent::redirect($url, $delay, $statusCode); }
$t->is($controller->convertUrlStringToParameters($url), $result, sprintf('->convertUrlStringToParameters() converts a symfony internal URI to an array of parameters (%s)', $url)); } try { $controller->convertUrlStringToParameters('@test?foobar'); $t->fail('->convertUrlStringToParameters() throw a sfParseException if it cannot parse the query string'); } catch (sfParseException $e) { $t->pass('->convertUrlStringToParameters() throw a sfParseException if it cannot parse the query string'); } // ->redirect() $t->diag('->redirect()'); $controller->redirect('module/action?id=1#photos'); $response = $context->getResponse(); $t->like($response->getContent(), '~http\://localhost/index.php/\?module=module&action=action&id=1#photos~', '->redirect() adds a refresh meta in the content'); $t->like($response->getHttpHeader('Location'), '~http\://localhost/index.php/\?module=module&action=action&id=1#photos~', '->redirect() adds a Location HTTP header'); // Test null url argument for ->redirect() try { $controller->redirect(null); $t->fail('->redirect() throw an InvalidArgumentException when the url argument is null'); } catch (InvalidArgumentException $iae) { $t->pass('->redirect() throw an InvalidArgumentException when the url argument is null'); } catch(Exception $e)
/** * @see sfFrontWebController */ public function redirect($url, $delay = 0, $statusCode = 302) { $this->dispatcher->notify(new sfEvent($this, 'dm.controller.redirect')); return parent::redirect($url, $delay, $statusCode); }