2012-05-02 29 views
2
  • 我在ActionContoller-Method:doSomeAction()中有。
  • 这一个在调用一个新的类,例如。我的DocumentManager,控制我的文档。
  • 此DocumentManager需要FileUploadManager。

确定...如何获得ActionController外的yml参数

  • ActionContoller - > DocumentManager - > FileUploadManager

现在我需要从我的配置文件中的一些参数保存在:应用程序/配置/ config.yml

  • 我想在Symfony的1.4使用类似:sfConfig ::得到( 'myVar的')......
  • 我不想写,每放慢参数池单独的服务....
  • 我不能定义所有的参数作为一个服务参数...

  • 此外,我不希望通过我与取得联系各阶层通过ActionController的(如AppKernel类似物体)...

回答

2

你有没有尝试使用解析器和自卸车:

use Symfony\Component\Yaml\Dumper; 
use Symfony\Component\Yaml\Parser; 


    private function readconfigFile(){ 
      $configFile = $baseUrl.'/config/config.yml'; 
      $yaml = new Parser(); 
      $configArray = $yaml->parse(file_get_contents($configFile)); 

      $readValue = $configArray['doctrine']['orm']['entity_managers']; 

      return $readValue; 

} 
+0

非常感谢您的注解.. 。 – ZappZone