我有一个包的语义配置,需要在同一包的编译器传递期间进行解释。
是否可以在不将其存储在中间容器变量中的情况下访问它?
最佳答案
是的,有点:
<?php
namespace Acme\DemoBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class CompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig('acme_demo');
}
}
据我所知
$configs
是未合并配置的数组,不包括默认值(由配置 TreeBuilder 定义的值)。见 here和 here
关于symfony - 我可以在编译器阶段访问语义配置吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15325146/