Symfony 2.8: isScopeActive impairment after upgrading to 2.8.0 from 2.7.7

I updated symfony 2.8 from 2.7.7 and I get this fatigue:

The Symfony \ Component \ DependencyInjection \ Container :: isScopeActive method has been deprecated since version 2.8 and will be removed in version 3.0.

I use this call in the twig extension class:

class TemplateHelper extends \Twig_Extension { private $request; private $container; /** * constructor * @param ContainerInterface $container */ public function __construct(ContainerInterface $container){ $this->container = $container; if( $this->container->isScopeActive('request') ){ $this->request = $this->container->get('request'); } } //...functions } 

First, I remove the isScopeActive check, but I get an exception when I run symfony cache:

[Symfony \ Component \ dependency injection \ Exception \ InactiveScopeException] You cannot create a service ("request") of an inactive area ("Request").

Is there a way to replace isScopeActive validation?

Thanks...

+6
source share
1 answer

Just enter request_stack instead of request and call getCurrentRequest () .

+8
source

All Articles