Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $configOne = $this->getBasicMock('\\horses\\config\\Config');
     $configTwo = $this->getBasicMock('\\horses\\config\\Config');
     $configOne->expects($this->any())->method('get')->will($this->returnValue('foo'));
     $factory = $this->getBasicMock('\\horses\\config\\Factory');
     $factory->expects($this->any())->method('getConfig')->will($this->returnValueMap([['one', $configOne], ['two', $configTwo]]));
     $this->collection = new Collection($factory);
     $this->collection->load('one')->load('two');
 }
Example #2
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 #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;
 }