繁体   English   中英

Symfony 2:学说缓存命名空间

[英]Symfony 2: Doctrine Cache Namespace

doctrine:
    orm:
        metadata_cache_driver:
            type: xcache
            namespace: %foobar%

嗨,我想通过%foobar%之类的参数设置学说缓存名称空间。 参数%foobar%将通过editorPass设置

class FoobarCompiler implements CompilerPassInterface {
    public function process(ContainerBuilder $container) {
        $container->setParameter('foobar', uniqid());
    }
}

并通过以下方式将此bundled编译器注册到捆绑类中:

public function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
    $container->addCompilerPass(new \FQNS\Compiler\FoobarCompiler());
}

但我得到这个错误:

[Symfony \\ Component \\ DependencyInjection \\ Exception \\ ParameterNotFoundException]您已请求一个不存在的参数“ foobar”。

知道如何通过此参数“ foobar”设置主义缓存名称空间吗?

greez&thx,天空...

答案是以下代码段:

class FoobarExtension extends Extension implements PrependExtensionInterface {

    ...

    public function prepend(ContainerBuilder $container) {
        $container->setParameter('foobar', uniqid());
    }
}

导入并添加“ PrependExtensionInterface”接口!

greez&thx,天空...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM