ar0*_*968 5 php symfony symfony-2.8
我从2.7.7更新到symfony 2.8,我得到了这个弃用:
从版本2.8开始,不推荐使用Symfony\Component\DependencyInjection\Container :: isScopeActive方法,并且将在3.0中删除它.
我在twig扩展类中使用此调用:
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
}
Run Code Online (Sandbox Code Playgroud)
首先我删除了isScopeActive检查,但是当我运行symfony cache clear时出现异常:
[Symfony\Component\DependencyInjection\Exception\InactiveScopeException]您无法创建非活动范围("请求")的服务("请求").
有没有办法替换isScopeActive检查?
谢谢...
| 归档时间: |
|
| 查看次数: |
1779 次 |
| 最近记录: |