我已经从 2.7.7 更新到 symfony 2.8 并且我得到了这个弃用:
Symfony\Component\DependencyInjection\Container::isScopeActive 方法自 2.8 版起已弃用,并将在 3.0 版中删除。
我在树枝扩展类中使用这个调用:
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
}
首先我删除了 isScopeActive 检查,但是当我运行 symfony 缓存清除时出现异常:
[Symfony\Component\DependencyInjection\Exception\InactiveScopeException] 您不能创建非活动范围(“请求”)的服务(“请求”)。
有什么方法可以代替 isScopeActive 检查吗?
谢谢...