Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * @expectedException \horses\config\UnknownConfigException
  */
 public function testGetSectionHasNone()
 {
     $this->collection->getSection('greublah');
 }
Example #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;
 }