示例#1
0
文件: Kernel.php 项目: alebear/horses
 /**
  * @return ConfigCollection
  * @throws KernelPanicException If configs dir cannot be read
  */
 public function getConfigCollection()
 {
     if (!$this->configCollection) {
         $configDir = $this->serverContext->getPath(ServerContext::DIR_CONFIG);
         if (!is_dir($configDir)) {
             throw new KernelPanicException(sprintf('Config dir does not exists or not readable: %s', $configDir));
         }
         $loader = new YamlFileLoader(new FileLocator([$configDir, $configDir . '/' . $this->serverContext->getEnvironment()]));
         $this->configCollection = new ConfigCollection(new Factory($loader, Config::class));
         $this->configCollection->load(self::CONFIG_SECTION);
     }
     return $this->configCollection;
 }
示例#2
0
 /**
  * @expectedException \horses\config\UnknownConfigException
  */
 public function testGetSectionHasNone()
 {
     $this->collection->getSection('greublah');
 }
示例#3
0
 /**
  * @param ConfigCollection $configCollection
  * @param ServerContext $serverContext
  */
 public function __construct(ConfigCollection $configCollection, ServerContext $serverContext)
 {
     $this->config = $configCollection->load(self::CONFIG_SECTION)->getSection(self::CONFIG_SECTION);
     $this->serverContext = $serverContext;
 }