Beispiel #1
0
 /**
  * Set active environment
  */
 public function setAction()
 {
     if (!ConfigService::isEnvironmentExists('local')) {
         if ($this->confirm('We need to create local environment to save your params. Ok', true)) {
             ConfigService::createEnvironment('local');
         }
     }
     $name = $this->ask('Enter name of environment');
     $config = ConfigService::getConfig('project', 'local');
     $config->set('activeEnvironment', 'local', 'local');
     $config->save();
     $this->notify('- You set active environment to <bold>' . $name . '</bold>');
 }
Beispiel #2
0
 public function testBasic()
 {
     ConfigService::setConfigsPath(self::$_configPath);
     $this->assertEquals(self::$_configPath, ConfigService::getConfigsPath(), 'Config path set correctly');
     $projectConfig = ConfigService::getConfig('project');
     $this->assertInstanceOf('\\Solve\\Config\\Config', $projectConfig, 'Service returned new instance of Config');
     $this->assertEquals('project', $projectConfig->getName(), 'Loaded correct config by name');
     $this->assertEquals('test', $projectConfig->get('project_name'), 'Data from project.yml');
     $this->assertEquals(false, $projectConfig->get('dev_mode'), 'General value loaded');
     ConfigService::loadEnvironment('local');
     $this->assertEquals(true, $projectConfig->get('dev_mode'), 'Local value loaded');
     ConfigService::loadEnvironment('youshido.com');
     $this->assertEquals(false, $projectConfig->get('dev_mode'), 'Overriden value loaded');
     ConfigService::loadEnvironment('local');
     $projectConfig->set('project_name', 'config test');
     $this->assertEquals('config test', $projectConfig->get('project_name'), 'update key in memory');
     $projectConfig->save();
 }
Beispiel #3
0
 /**
  * @param $name
  * @param null $deepKey
  * @return ArrayStorage|Config
  */
 public static function getConfig($name, $deepKey = null, $defaultValue = null)
 {
     return $deepKey ? ConfigService::getConfig($name)->get($deepKey) : ConfigService::getConfig($name);
 }