简体   繁体   中英

Symfony 2: Doctrine Cache Namespace

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

hi, i want set the doctrine cache namespace via parameter like %foobar%. the parameter %foobar% will set via compilerPass

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

and this compilerPass ist register in a bundle class via:

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

but i get this error:

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

any idea how can i set the doctrine cache namespace via this parameter "foobar" ?

greez & thx, sky...

the answer is this snippet:

class FoobarExtension extends Extension implements PrependExtensionInterface {

    ...

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

it is importand to add the "PrependExtensionInterface" interface !

greez & thx, sky...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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