【发布时间】:2015-04-14 17:24:13
【问题描述】:
我在这里遇到了一个问题,我不知道为什么或在哪里失败,也许我错过了一些配置,无论如何,我在DependencyInjection\AppExtension.php 文件中有此代码:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class AppExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
然后在Resources/config/services.yml 我有这个:
services:
pdone.twig.extension:
class: GroupDCA\PDOneBundle\Extension\PDOneTwigExtension
tags:
- { name: twig.extension }
由于某种原因无法正常工作。这意味着我收到了这个错误:
第 1 行的 PDOneBundle::pdone.html.twig 中不存在过滤器“empty”
现在,如果我将服务定义移动到 config/config.yml,则会收到此错误:
编译错误:无法对表达式的结果使用 isset()(您可以改用“null !== expression”)
这让我认为捆绑包没有通过 DependecyInjection,我在这里缺少什么?为什么会出现不同的错误?
【问题讨论】:
标签: php symfony dependency-injection symfony-2.7