[FrameworkBundle] removed usage of Controller class for internal controllers

This commit is contained in:
Fabien Potencier 2010-08-30 07:26:19 +02:00
parent b1b3ce83ae
commit 6b5c3d05bd
5 changed files with 20 additions and 20 deletions

View File

@ -2,8 +2,8 @@
namespace Symfony\Bundle\FrameworkBundle\Controller; namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
/* /*
* This file is part of the Symfony framework. * This file is part of the Symfony framework.
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/ */
class DefaultController extends Controller class DefaultController extends ContainerAware
{ {
/** /**
* Renders the Symfony2 welcome page. * Renders the Symfony2 welcome page.
@ -28,6 +28,6 @@ class DefaultController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
return $this['templating']->renderResponse('FrameworkBundle:Default:index'); return $this->container->get('templating')->renderResponse('FrameworkBundle:Default:index');
} }
} }

View File

@ -2,7 +2,7 @@
namespace Symfony\Bundle\FrameworkBundle\Controller; namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\OutputEscaper\SafeDecorator; use Symfony\Component\OutputEscaper\SafeDecorator;
@ -21,7 +21,7 @@ use Symfony\Component\OutputEscaper\SafeDecorator;
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/ */
class ExceptionController extends Controller class ExceptionController extends ContainerAware
{ {
/** /**
* Converts an Exception to a Response. * Converts an Exception to a Response.
@ -35,15 +35,15 @@ class ExceptionController extends Controller
*/ */
public function exceptionAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html', $embedded = false) public function exceptionAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html', $embedded = false)
{ {
$this['request']->setRequestFormat($format); $this->container->get('request')->setRequestFormat($format);
$currentContent = ''; $currentContent = '';
while (false !== $content = ob_get_clean()) { while (false !== $content = ob_get_clean()) {
$currentContent .= $content; $currentContent .= $content;
} }
$response = $this->render( $response = $this->container->get('templating')->renderResponse(
'FrameworkBundle:Exception:'.($this['kernel']->isDebug() ? 'exception' : 'error'), 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error'),
array( array(
'exception' => new SafeDecorator($exception), 'exception' => new SafeDecorator($exception),
'logger' => $logger, 'logger' => $logger,

View File

@ -2,7 +2,7 @@
namespace Symfony\Bundle\FrameworkBundle\Controller; namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/* /*
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/ */
class InternalController extends Controller class InternalController extends ContainerAware
{ {
/** /**
* Forwards to the given controller with the given path. * Forwards to the given controller with the given path.
@ -31,7 +31,7 @@ class InternalController extends Controller
*/ */
public function indexAction($path, $controller) public function indexAction($path, $controller)
{ {
$request = $this['request']; $request = $this->container->get('request');
$attributes = $request->attributes; $attributes = $request->attributes;
$attributes->delete('path'); $attributes->delete('path');
@ -42,6 +42,6 @@ class InternalController extends Controller
$attributes->add($tmp); $attributes->add($tmp);
} }
return $this['controller_resolver']->forward($controller, $attributes->all(), $request->query->all()); return $this->container->get('controller_resolver')->forward($controller, $attributes->all(), $request->query->all());
} }
} }

View File

@ -2,7 +2,7 @@
namespace Symfony\Bundle\FrameworkBundle\Controller; namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/* /*
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/ */
class RedirectController extends Controller class RedirectController extends ContainerAware
{ {
/** /**
* Redirects to another route. * Redirects to another route.
@ -38,7 +38,7 @@ class RedirectController extends Controller
public function redirectAction($route, $permanent = false) public function redirectAction($route, $permanent = false)
{ {
if (!$route) { if (!$route) {
$response = $this['response']; $response = $this->container->get('response');
$response->setStatusCode(410); $response->setStatusCode(410);
return $response; return $response;
@ -46,10 +46,10 @@ class RedirectController extends Controller
$code = $permanent ? 301 : 302; $code = $permanent ? 301 : 302;
$attributes = $this['request']->attributes->all(); $attributes = $this->container->get('request')->attributes->all();
unset($attributes['_route'], $attributes['route']); unset($attributes['_route'], $attributes['route']);
$response = $this['response']; $response = $this->container->get('response');
$response->setRedirect($this['router']->generate($route, $attributes), $code); $response->setRedirect($this['router']->generate($route, $attributes), $code);
return $response; return $response;

View File

@ -2,7 +2,7 @@
namespace Symfony\Bundle\FrameworkBundle\Controller; namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
/* /*
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/ */
class TemplateController extends Controller class TemplateController extends ContainerAware
{ {
/** /**
* Renders a template. * Renders a template.
@ -30,6 +30,6 @@ class TemplateController extends Controller
*/ */
public function templateAction($template) public function templateAction($template)
{ {
return $this['templating']->renderResponse($template); return $this->container->get('templating')->renderResponse($template);
} }
} }