diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php index 4b7ec9a07630..a7bb6bbd930f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/DefaultController.php @@ -3,6 +3,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Components\HttpFoundation\Response; /* * This file is part of the Symfony framework. @@ -20,8 +21,13 @@ */ class DefaultController extends Controller { + /** + * Renders the Symfony2 welcome page. + * + * @return Response A Response instance + */ public function indexAction() { - return $this->render('FrameworkBundle:Default:index'); + return $this['templating']->renderResponse('FrameworkBundle:Default:index'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php index 602294cf9f3c..7165eb737a3e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php @@ -25,13 +25,18 @@ class ExceptionController extends Controller { /** + * Converts an Exception to a Response. + * + * @param \Exception $exception An Exception instance + * @param Request $request The original Request instance + * @param array $logs An array of logs + * * @throws \InvalidArgumentException When the exception template does not exist */ public function exceptionAction(\Exception $exception, Request $originalRequest, array $logs) { $template = $this->container->getParameter('kernel.debug') ? 'exception' : 'error'; - $request = $this->getRequest(); $format = $format = $originalRequest->getRequestFormat(); // when using CLI, we force the format to be TXT @@ -39,7 +44,7 @@ public function exceptionAction(\Exception $exception, Request $originalRequest, $format = 'txt'; } - $template = $this->container->getTemplatingService()->getLoader()->load($template, array( + $template = $this['templating']->getLoader()->load($template, array( 'bundle' => 'FrameworkBundle', 'controller' => 'Exception', 'format' => '.'.$format, @@ -73,7 +78,7 @@ public function exceptionAction(\Exception $exception, Request $originalRequest, require $template; $content = ob_get_clean(); - $response = $this->container->getResponseService(); + $response = $this['response']; $response->setStatusCode($code); $response->setContent($content); diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php index 061a52fb6e52..95f03a0daca6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/InternalController.php @@ -3,6 +3,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Components\HttpFoundation\Response; /* * This file is part of the Symfony framework. @@ -20,16 +21,25 @@ */ class InternalController extends Controller { - public function indexAction() + /** + * Forwards to the given controller with the given path. + * + * @param string $path The path + * @param string $controller The controller name + * + * @return Response A Response instance + */ + public function indexAction($path, $controller) { - $request = $this->getRequest(); + $request = $this['request']; + $attributes = $request->attributes; - if ('none' !== $request->attributes->get('path')) + if ('none' !== $path) { - parse_str($request->attributes->get('path'), $tmp); - $request->attributes->add($tmp); + parse_str($path, $tmp); + $attributes->add($tmp); } - return $this->forward($request->attributes->get('controller'), $request->attributes->all(), $request->query->all()); + return $this['controller_resolver']->forward($controller, $attributes->all(), $request->query->all()); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 5d00b2c6a537..46fe9d81985d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -3,6 +3,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Components\HttpFoundation\Response; /* * This file is part of the Symfony framework. @@ -20,7 +21,7 @@ */ class RedirectController extends Controller { - /* + /** * Redirects to another route. * * It expects a route path parameter. @@ -28,11 +29,16 @@ class RedirectController extends Controller * * If the route empty, the status code will be 410. * If the permanent path parameter is set, the status code will be 302. + * + * @param string $route The route pattern to redirect to + * @param Boolean $permanent Whether the redirect is permanent or not + * + * @return Response A Response instance */ public function redirectAction($route, $permanent = false) { if (!$route) { - $response = $this->container->getResponseService(); + $response = $this['response']; $response->setStatusCode(410); return $response; @@ -40,9 +46,12 @@ public function redirectAction($route, $permanent = false) $code = $permanent ? 301 : 302; - $parameters = $this->getRequest()->getPathParameters(); - unset($parameters['_route'], $parameters['route']); + $attributes = $this['request']->attributes->all(); + unset($attributes['_route'], $attributes['route']); + + $response = $this['response']; + $response->setRedirect($this['router']->generate($route, $attributes), $code); - return $this->redirect($this->container->getRouterService()->generate($route, $parameters), $code); + return $response; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 140033f49c53..a66dd4bd406d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -3,6 +3,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Components\HttpFoundation\Response; /* * This file is part of the Symfony framework. @@ -20,8 +21,15 @@ */ class TemplateController extends Controller { + /** + * Renders a template. + * + * @param string $template The template name + * + * @return Response A Response instance + */ public function templateAction($template) { - return $this->render($template); + return $this['templating']->renderResponse($template); } }