فهرست منبع

Merge remote branch 'weaverryan/controller_redirect'

Fabien Potencier 14 سال پیش
والد
کامیت
b0cee4527a
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 14 0
      src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

+ 14 - 0
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.
      *