addScope() public method

Adds a scope to the container
public addScope ( Symfony\Component\DependencyInjection\ScopeInterface $scope ) : void
$scope Symfony\Component\DependencyInjection\ScopeInterface
return void
 /**
  * Adds the Contao scopes to the container.
  */
 private function addContaoScopesIfNotSet()
 {
     if (!$this->container->hasScope(ContaoCoreBundle::SCOPE_BACKEND)) {
         $this->container->addScope(new Scope(ContaoCoreBundle::SCOPE_BACKEND, 'request'));
     }
     if (!$this->container->hasScope(ContaoCoreBundle::SCOPE_FRONTEND)) {
         $this->container->addScope(new Scope(ContaoCoreBundle::SCOPE_FRONTEND, 'request'));
     }
 }
 /**
  * Constructor.
  *
  * @param EventDispatcherInterface    $dispatcher         An EventDispatcherInterface instance
  * @param ContainerInterface          $container          A ContainerInterface instance
  * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
  */
 public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
 {
     parent::__construct($dispatcher, $controllerResolver);
     $this->container = $container;
     // the request scope might have been created before (see FrameworkBundle)
     if (!$container->hasScope('request')) {
         $container->addScope(new Scope('request'));
     }
 }
 /**
  * Constructor.
  *
  * @param EventDispatcherInterface    $dispatcher         An EventDispatcherInterface instance
  * @param ContainerInterface          $container          A ContainerInterface instance
  * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
  * @param RequestStack                $requestStack       A stack for master/sub requests
  * @param bool                        $triggerDeprecation Whether or not to trigger the deprecation warning for the ContainerAwareHttpKernel
  */
 public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null, $triggerDeprecation = true)
 {
     parent::__construct($dispatcher, $controllerResolver, $requestStack);
     if ($triggerDeprecation) {
         @trigger_error('The ' . __CLASS__ . ' class is deprecated since version 2.7 and will be removed in 3.0. Use the Symfony\\Component\\HttpKernel\\HttpKernel class instead.', E_USER_DEPRECATED);
     }
     $this->container = $container;
     // the request scope might have been created before (see FrameworkBundle)
     if (!$container->hasScope('request')) {
         $container->addScope(new Scope('request'));
     }
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function addScope(ScopeInterface $scope)
 {
     $this->container->addScope($scope);
 }
Example #5
0
 public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null)
 {
     parent::__construct($dispatcher, $controllerResolver, $requestStack);
     $this->container = $container;
     if (!$container->hasScope('request')) {
         $container->addScope(new Scope('request'));
     }
 }
 /**
  * Constructor.
  *
  * @param EventDispatcherInterface    $dispatcher         An EventDispatcherInterface instance
  * @param ContainerInterface          $container          A ContainerInterface instance
  * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
  */
 public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
 {
     parent::__construct($dispatcher, $controllerResolver);
     $this->container = $container;
     $container->addScope(new Scope('request'));
 }