2014-02-27 68 views
1
doctrine: 
    orm: 
     metadata_cache_driver: 
      type: xcache 
      namespace: %foobar% 

嗨,我想通过参数像%foobar%设置教义缓存命名空间。参数%FOOBAR%将通过compilerPassSymfony 2:Doctrine缓存命名空间

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

这compilerPass IST寄存器中捆绑类通过设置:

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

,但我得到这个错误:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] You have requested a non-existent parameter "foobar".

任何想法如何我可以通过这个参数“foobar”设置教义缓存命名空间吗?

greez & THX, 天空...

回答

2

的答案是这样的片段:

class FoobarExtension extends Extension implements PrependExtensionInterface { 

    ... 

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

是importand添加 “PrependExtensionInterface” 界面!

greez & thx, sky ...

相关问题