|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\FrameworkBundle\Controller; |
| 13 | + |
| 14 | +use Psr\Container\ContainerInterface; |
| 15 | +use Doctrine\Common\Persistence\ManagerRegistry; |
| 16 | +use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; |
| 17 | +use Symfony\Component\Form\FormFactoryInterface; |
| 18 | +use Symfony\Component\HttpFoundation\RequestStack; |
| 19 | +use Symfony\Component\HttpFoundation\Session\Session; |
| 20 | +use Symfony\Component\HttpFoundation\Session\SessionInterface; |
| 21 | +use Symfony\Component\HttpKernel\HttpKernelInterface; |
| 22 | +use Symfony\Component\Routing\RouterInterface; |
| 23 | +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
| 24 | +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
| 25 | +use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; |
| 26 | +use Symfony\Component\Serializer\SerializerInterface; |
| 27 | +use Symfony\Component\Templating\EngineInterface; |
| 28 | + |
| 29 | +/** |
| 30 | + * Provides common features needed in controllers. |
| 31 | + * |
| 32 | + * @author Fabien Potencier <[email protected]> |
| 33 | + */ |
| 34 | +abstract class AbstractController implements ServiceSubscriberInterface |
| 35 | +{ |
| 36 | + use ControllerTrait; |
| 37 | + |
| 38 | + private $container; |
| 39 | + |
| 40 | + /** |
| 41 | + * @internal |
| 42 | + * @required |
| 43 | + */ |
| 44 | + public function setContainer(ContainerInterface $container) |
| 45 | + { |
| 46 | + $previous = $this->container; |
| 47 | + $this->container = $container; |
| 48 | + |
| 49 | + return $previous; |
| 50 | + } |
| 51 | + |
| 52 | + public static function getSubscribedServices() |
| 53 | + { |
| 54 | + return array( |
| 55 | + 'router' => '?'.RouterInterface::class, |
| 56 | + 'request_stack' => '?'.RequestStack::class, |
| 57 | + 'http_kernel' => '?'.HttpKernelInterface::class, |
| 58 | + 'serializer' => '?'.SerializerInterface::class, |
| 59 | + 'session' => '?'.SessionInterface::class, |
| 60 | + 'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class, |
| 61 | + 'templating' => '?'.EngineInterface::class, |
| 62 | + 'twig' => '?'.\Twig_Environment::class, |
| 63 | + 'doctrine' => '?'.ManagerRegistry::class, |
| 64 | + 'form.factory' => '?'.FormFactoryInterface::class, |
| 65 | + 'security.token_storage' => '?'.TokenStorageInterface::class, |
| 66 | + 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, |
| 67 | + ); |
| 68 | + } |
| 69 | +} |
0 commit comments