public function loadEnvironment($environmentName) { $environmentPath = ConfigService::getConfigsPath() . $environmentName . '/' . $this->_name . '.yml'; $this->_loadedEnvironmentName = $environmentName; if (is_file($environmentPath)) { $this->_environmentData = new YamlStorage($environmentPath); $this->_combinedData->extendDeepValue($this->_environmentData->getData()); } return $this; }
public function onEnvironmentUpdate(BaseEvent $event) { ConfigService::setConfigsPath(DC::getEnvironment()->getConfigRoot()); ConfigService::loadAllConfigs(); DC::getLogger()->setLogsPath(DC::getEnvironment()->getTmpRoot() . 'log'); DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot(), true); DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/bases'); DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/classes'); DC::getAutoloader()->registerNamespaceSharedPaths(DC::getEnvironment()->getUserClassesRoot() . 'classes/', true); FilesAbility::setBaseStoreLocation(DC::getEnvironment()->getUploadRoot()); }
/** * 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>'); }
/** * Using for generating profile for database * @help Using for generating profile for database * @optional [profile name] to specify profile */ public function wizardAction() { $this->writeln('DB wizard for a profile'); $profileName = $this->ask('Enter the <underline>profile name</underline> to edit', 'default'); $fields = $this->askArray(array('name' => array('DB name'), 'user' => array('DB user', 'root'), 'pass' => array('DB password', 'root'), 'host' => array('DB host', '127.0.0.1'))); if ($this->confirm('Write to file', true)) { $config = DC::getDatabaseConfig(); foreach ($fields as $field => $value) { $config->set('profiles/' . $profileName . '/' . $field, $value); } $config->save(); $this->notify(ConfigService::getConfigsPath() . 'database.yml', 'saved'); } else { $this->writeln('exiting.'); } }
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(); }
/** * @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); }