I've updated to symfony 2.8 from 2.7.7 and i get this deprecation:
The Symfony\Component\DependencyInjection\Container::isScopeActive method is deprecated since version 2.8 and will be removed in 3.0.
I use this call in a 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
    }
Firstly i delete the isScopeActive check, but i get an exception when i run the symfony cache clear:
[Symfony\Component\DependencyInjection\Exception\InactiveScopeException] You cannot create a service ("request") of an inactive scope ("request").
Is there any way to replace the isScopeActive check?
Thanks...
Simply inject request_stack instead of request and call getCurrentRequest().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With