2013-09-05 3 views
-1

에 구성 값을 참조 할 수 있습니다 방법 :나는 Symfony2 구성을 감안할 때 Symfony2

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

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

가 어떻게 logFile하게 tempFolder에 따라 달라질 수 있습니다 그래서

tempFolder + '/' + logFile 

답변

0

이럴처럼 것을, 그것은 아무것도가 없습니다 구성을 다룬다. 심포니의 설정은 이며, 확인은 단지입니다. 의 유효성을 검사하려면 어떻게해야합니까?

이것은 내선 번호 작업입니다.

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% 
에 액세스 할 수 있습니다