public function onKernelReady(BaseEvent $event) { $this->onEnvironmentUpdate($event); if ($webRoot = DC::getProjectConfig('webRoot')) { DC::getEnvironment()->setWebRoot($webRoot); } $databaseConfig = DC::getDatabaseConfig(); $request = DC::getRouter()->getCurrentRequest(); if ($profiles = $databaseConfig->get('profiles')) { foreach ($profiles as $profileName => $profileInfo) { DatabaseService::configProfile($profileInfo, $profileName); } if (empty($request) || $request && !$request->isConsoleRequest()) { ModelOperator::getInstance(DC::getEnvironment()->getUserClassesRoot() . 'db/'); if ($databaseConfig->get('autoUpdateAll')) { ModelOperator::getInstance()->generateAllModelClasses()->updateDBForAllModels(); } } } }
/** * Created database for profile default */ public function createDbAction() { $config = DC::getDatabaseConfig('profiles/default'); DatabaseService::configProfile(array('user' => $config['user'], 'pass' => $config['pass'])); DBOperator::getInstance()->createDB($config['name']); $this->notify($config['name'], '+Database created:'); }