-1

给定一个 Symfony2 配置:

$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('acme');        

$rootNode
    ->children()
        ->scalarNode('tempFolder')
            ->isRequired()
            ->cannotBeEmpty()
        ->end()
        ->scalarNode('logFile')
        ->end()
    ->end()
;

我怎样才能logFile依赖tempFolder它就像

tempFolder + '/' + logFile
4

1 回答 1

0

恕我直言,它与配置无关。symfony 中的配置几乎只是验证。您需要验证什么?

这看起来像是您的扩展的工作。

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $logRealpath = sprintf("%s/%s",
        rtrim($config['tempFolder'], '/'), 
        ltrim($config['logFile'], '/')
    );
    $container->setParameter('acme.log_realpath', $logRealpath);
}

然后你可以访问它

%acme.log_realpath%
于 2013-09-05T14:43:56.873 回答