Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FrameworkBundle] Introduce AbstractController, replacing ControllerT…
…rait
- Loading branch information
1 parent
8901c7e
commit a93f059
Showing
10 changed files
with
736 additions
and
1,502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Controller; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; | ||
use Symfony\Component\Form\FormFactoryInterface; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\HttpFoundation\Session\Session; | ||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | ||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
use Symfony\Component\Templating\EngineInterface; | ||
|
||
/** | ||
* Provides common features needed in controllers. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
abstract class AbstractController implements ServiceSubscriberInterface | ||
{ | ||
use ControllerTrait; | ||
|
||
private $container; | ||
|
||
/** | ||
* @internal | ||
* @required | ||
*/ | ||
public function setContainer(ContainerInterface $container) | ||
{ | ||
$previous = $this->container; | ||
$this->container = $container; | ||
|
||
return $previous; | ||
} | ||
|
||
public static function getSubscribedServices() | ||
{ | ||
return array( | ||
'router' => '?'.RouterInterface::class, | ||
'request_stack' => '?'.RequestStack::class, | ||
'http_kernel' => '?'.HttpKernelInterface::class, | ||
'serializer' => '?'.SerializerInterface::class, | ||
'session' => '?'.SessionInterface::class, | ||
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class, | ||
'templating' => '?'.EngineInterface::class, | ||
'twig' => '?'.\Twig_Environment::class, | ||
'doctrine' => '?'.ManagerRegistry::class, | ||
'form.factory' => '?'.FormFactoryInterface::class, | ||
'security.token_storage' => '?'.TokenStorageInterface::class, | ||
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, | ||
); | ||
} | ||
} |
Oops, something went wrong.