2017-03-25 12:43:01 +00:00
|
|
|
<?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;
|
2017-12-11 15:53:16 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
2017-03-25 12:43:01 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
|
|
|
use Symfony\Component\Form\FormFactoryInterface;
|
|
|
|
use Symfony\Component\HttpFoundation\RequestStack;
|
|
|
|
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;
|
2017-06-02 09:55:39 +01:00
|
|
|
use Twig\Environment;
|
2017-03-25 12:43:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides common features needed in controllers.
|
|
|
|
*
|
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
*/
|
|
|
|
abstract class AbstractController implements ServiceSubscriberInterface
|
|
|
|
{
|
|
|
|
use ControllerTrait;
|
|
|
|
|
2017-06-14 17:24:40 +01:00
|
|
|
/**
|
|
|
|
* @var ContainerInterface
|
|
|
|
*/
|
|
|
|
protected $container;
|
2017-03-25 12:43:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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,
|
2017-06-02 09:55:39 +01:00
|
|
|
'twig' => '?'.Environment::class,
|
2017-03-25 12:43:01 +00:00
|
|
|
'doctrine' => '?'.ManagerRegistry::class,
|
|
|
|
'form.factory' => '?'.FormFactoryInterface::class,
|
|
|
|
'security.token_storage' => '?'.TokenStorageInterface::class,
|
|
|
|
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
|
2017-12-11 15:53:16 +00:00
|
|
|
'parameter_bag' => '?'.ContainerBagInterface::class,
|
2017-03-25 12:43:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|