symfony - 我可以在编译器阶段访问语义配置吗?

标签 symfony configuration dependency-injection

我有一个包的语义配置,需要在同一包的编译器传递期间进行解释。

是否可以在不将其存储在中间容器变量中的情况下访问它?

最佳答案

是的,有点:

<?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 定义的值)。

herehere

关于symfony - 我可以在编译器阶段访问语义配置吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15325146/

相关文章:

node.js - 通过 TOR 使用 Node 的 HTTP 请求问题

行为附加到注释的 Java 设计问题

android - Roboguice 2.0 @Inject 单例到 POJO

php - Symfony2 : How to remove an element from a Doctrine ArrayCollection (many-to-many relation)?

symfony - Doctrine - Criteria - expressions - 包含(多对多)

mysql - 如何创建root管理用户root :rootroot for MySQL?

java - 使用 Builder 模式为客户端库注入(inject) Guice

symfony - Symfony2注销CSRF保护: csrf_provider unrecognized

html - Symfony2 : How to render an HTML5 number input type and accept float values in a form?

linux - 在 Linux Mint 14 Nadia 上使用 Apache2 配置 Request Tracker 4.0