/**
  * Execute current command
  *
  * @param oxIOutput $oOutput
  */
 public function execute(oxIOutput $oOutput)
 {
     $sMigrationsDir = OX_BASE_PATH . 'migration' . DIRECTORY_SEPARATOR;
     $sTemplatePath = $this->_getTemplatePath();
     $sMigrationName = $this->_parseMigrationNameFromInput();
     if (!$sMigrationName) {
         do {
             $sMigrationName = $this->_askForMigrationNameInput();
         } while (!$sMigrationName);
     }
     $sMigrationFilePath = $sMigrationsDir . oxMigrationQuery::getCurrentTimestamp() . '_' . strtolower($sMigrationName) . '.php';
     /** @var Smarty $oSmarty */
     $oSmarty = oxRegistry::get('oxUtilsView')->getSmarty();
     $oSmarty->assign('sMigrationName', $sMigrationName);
     $sContent = $oSmarty->fetch($sTemplatePath);
     file_put_contents($sMigrationFilePath, $sContent);
 }
Ejemplo n.º 2
0
 /**
  * Parse timestamp from user input
  *
  * @return string
  *
  * @throws oxConsoleException
  */
 protected function _parseTimestamp()
 {
     $oInput = $this->getInput();
     if ($sTimestamp = $oInput->getArgument(1)) {
         if (!oxMigrationQuery::isValidTimestamp($sTimestamp)) {
             if ($sTime = strtotime($sTimestamp)) {
                 $sTimestamp = date('YmdHis', $sTime);
             } else {
                 /** @var oxConsoleException $oEx */
                 $oEx = oxNew('oxConsoleException');
                 $oEx->setMessage('Invalid timestamp format, use YYYYMMDDhhmmss format');
                 throw $oEx;
             }
         }
         return $sTimestamp;
     }
     return oxMigrationQuery::getCurrentTimestamp();
 }
 /**
  * Add query
  *
  * @param oxMigrationQuery $oQuery The query to be added
  */
 public function addQuery(oxMigrationQuery $oQuery)
 {
     $this->_aQueries[$oQuery->getTimestamp()] = $oQuery;
 }