gpt4 book ai didi

php - Symfony 2 : Doctrine Cache Namespace

转载 作者:行者123 更新时间:2023-12-04 16:54:55 25 4
gpt4 key购买 nike

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

嗨,我想通过像 %foobar% 这样的参数设置学说缓存命名空间。参数 %foobar% 将通过 compilerPass 设置
class FoobarCompiler implements CompilerPassInterface {
public function process(ContainerBuilder $container) {
$container->setParameter('foobar', uniqid());
}
}

并且这个 compilerPass 是通过以下方式注册到一个包类中的:
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”设置学说缓存命名空间?

格里兹和thx,
天空...

最佳答案

答案是这个片段:

class FoobarExtension extends Extension implements PrependExtensionInterface {

...

public function prepend(ContainerBuilder $container) {
$container->setParameter('foobar', uniqid());
}
}
添加“PrependExtension Interface”接口(interface)很重要!
greez & thx, 天空...

关于php - Symfony 2 : Doctrine Cache Namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22073802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com