/** * @Route("/extra.{_format}", name="_extra_noname", defaults={"_format"="html"}), * @Route("/extra/{name}.{_format}", name="_extra_name", defaults={"_format"="html"}) * @View() */ public function indexAction($name = null) { if (!$name) { return RedirectView::create('http://liip.ch'); } return array('name' => $name); }
public function testSetLocation() { $url = 'users'; $code = 500; $view = RedirectView::create($url, $code); $this->assertAttributeEquals($url, 'location', $view); $this->assertAttributeEquals(null, 'route', $view); $this->assertEquals($code, $view->getResponse()->getStatusCode()); $view = new View(); $location = 'location'; $view->setLocation($location); $this->assertEquals($location, $view->getLocation()); }
/** * Create a Redirect view * * Convenience method to allow for a fluent interface. * * @param string $url * @param integer $statusCode * @param array $headers * * @return View */ protected function redirectView($url, $statusCode = Codes::HTTP_FOUND, array $headers = array()) { return RedirectView::create($url, $statusCode, $headers); }