protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->init($input);
     // Main insert.sql file
     $content = file_get_contents(THELIA_SETUP_DIRECTORY . 'insert.sql.tpl');
     $version = Version::parse();
     $content = $this->parser->renderString($content, $version, false);
     if (false === file_put_contents(THELIA_SETUP_DIRECTORY . 'insert.sql', $content)) {
         $output->writeln("Can't write file " . THELIA_SETUP_DIRECTORY . 'insert.sql');
     } else {
         $output->writeln("File " . THELIA_SETUP_DIRECTORY . 'insert.sql generated successfully.');
     }
     // sql update files
     $finder = Finder::create()->name('*.tpl')->depth(0)->in(THELIA_SETUP_DIRECTORY . 'update' . DS . 'tpl');
     /** @var \SplFileInfo $file */
     foreach ($finder as $file) {
         $content = file_get_contents($file->getRealPath());
         $content = $this->parser->renderString($content, [], false);
         $destination = THELIA_SETUP_DIRECTORY . 'update' . DS . 'sql' . DS . $file->getBasename('.tpl');
         if (false === file_put_contents($destination, $content)) {
             $output->writeln("Can't write file " . $destination);
         } else {
             $output->writeln("File " . $destination . ' generated successfully.');
         }
     }
 }
Beispiel #2
0
 public function getWebVersion()
 {
     $url = "http://thelia.net/version.php";
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($curl, CURLOPT_TIMEOUT, 5);
     $res = curl_exec($curl);
     try {
         if (Version::parse($res)) {
             return $res;
         }
     } catch (\Exception $e) {
         return null;
     }
 }
Beispiel #3
0
 /**
  * @dataProvider exceptionParseProvider
  * @expectedException InvalidArgumentException
  */
 public function testExceptionParse($version)
 {
     Tester::parse($version);
 }
Beispiel #4
0
 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;
 }