6
更新到2.8.0后isScopeActive贬低我从2.7.7更新到symfony的2.8和我得到这个弃用:Symfony的2.8:从2.7.7
symfony的\分量\ DependencyInjection \容器: :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检查?
谢谢...
这是类似于替换的方式,即$ this-> container-> isScopeActive('request')'被'$ requestStack-> getCurrentRequest()'替换吗? – crmpicco