/** * Устанавливает значение конфига * * @param $config_name * @param $config_value * @throws \Exception * @throws \PropelException */ public static function set($config_name, $config_value) { $isset_config_value = self::get($config_name); if ($isset_config_value) { $config = ConfigQuery::create()->findOneByName($config_name); } else { $config = new Config(); $config->setName($config_name)->setValue($config_value)->save(); } self::$data[$config_name] = $config_value; }
public function process() { $this->updatedVersions = array(); $currentVersion = $this->getCurrentVersion(); $this->log('debug', "start update process"); if (true === $this->isLatestVersion($currentVersion)) { $this->log('debug', "You already have the latest version. No update available"); throw new UpToDateException('You already have the latest version. No update available'); } $index = array_search($currentVersion, $this->version); $this->connection->beginTransaction(); $database = new Database($this->connection); $version = null; try { $size = count($this->version); for ($i = ++$index; $i < $size; $i++) { $version = $this->version[$i]; $this->updateToVersion($version, $database); $this->updatedVersions[] = $version; } $currentVersion = Version::parse(); $this->log('debug', sprintf('setting database configuration to %s', $currentVersion['version'])); $updateConfigVersion = ['thelia_version' => $currentVersion['version'], 'thelia_major_version' => $currentVersion['major'], 'thelia_minus_version' => $currentVersion['minus'], 'thelia_release_version' => $currentVersion['release'], 'thelia_extr_version' => $currentVersion['extra']]; foreach ($updateConfigVersion as $name => $value) { ConfigQuery::write($name, $value); } $this->connection->commit(); $this->log('debug', 'update successfully'); } catch (\Exception $e) { $this->connection->rollBack(); $this->log('error', sprintf('error during update process with message : %s', $e->getMessage())); $ex = new UpdateException($e->getMessage(), $e->getCode(), $e->getPrevious()); $ex->setVersion($version); throw $ex; } $this->log('debug', 'end of update processing'); return $this->updatedVersions; }