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