From 9ee9f5552b43010dbbefac0cf2654cb70b8e91d2 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 22 Mar 2011 08:21:07 -0500 Subject: [PATCH] [FrameworkBundle] Adding the redirect method back to the base controller Some question whether or not the base Controller should be included at all. I think it absolutely must be included because it's important for beginners and for rapid development of smaller features/applications (and rapid development is good for beginners). So, assuming that we *do* like the base Controller, we should really use it to its fullest potential - making the lives of developers as easy as possible. --- .../FrameworkBundle/Controller/Controller.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index 3b2a49efbc..bcc1b15d56 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerAware; /** @@ -51,6 +52,19 @@ class Controller extends ContainerAware return $this->container->get('http_kernel')->forward($controller, $path, $query); } + /** + * Returns a RedirectResponse to the given URL. + * + * @param string $url The URL to redirect to + * @param integer $status The status code to use for the Response + * + * @return RedirectResponse + */ + public function redirect($url, $status = 302) + { + return new RedirectResponse($url, $status); + } + /** * Returns a rendered view. *