/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $oInput = $this->getInput(); $oDebugOutput = $oInput->hasOption(array('n', 'no-debug')) ? oxNew('oxNullOutput') : $oOutput; try { $aModuleIds = $this->_parseModuleIds(); $aShopConfigs = $this->_parseShopConfigs(); } catch (oxInputException $oEx) { $oOutput->writeLn($oEx->getMessage()); return; } /** @var oxModuleStateFixer $oModuleStateFixer */ $oModuleStateFixer = oxRegistry::get('oxModuleStateFixer'); /** @var oxModule $oModule */ $oModule = oxNew('oxModule'); foreach ($aShopConfigs as $oConfig) { $oDebugOutput->writeLn('[DEBUG] Working on shop id ' . $oConfig->getShopId()); foreach ($aModuleIds as $sModuleId) { if (!$oModule->load($sModuleId)) { $oDebugOutput->writeLn("[DEBUG] {$sModuleId} can not be loaded - skipping"); continue; } $oDebugOutput->writeLn("[DEBUG] Fixing {$sModuleId} module"); $oModuleStateFixer->fix($oModule, $oConfig); } $oDebugOutput->writeLn(); } $oOutput->writeLn('Fixed module states successfully'); }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $oOutput->writeLn('Updating database views'); /** @var oxDbMetaDataHandler $oDbHandler */ $oDbHandler = oxNew('oxDbMetaDataHandler'); if (!$oDbHandler->updateViews()) { $oOutput->writeLn('[ERROR] Could not update database views'); return; } $oOutput->writeLn('Database views updated successfully'); }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $aCommands = $this->getConsoleApplication()->getLoadedCommands(); $oOutput->writeLn('OXID Shop console'); $oOutput->writeLn(); $oOutput->writeLn('Available commands:'); $iOffset = max(array_map('strlen', array_keys($aCommands))) + 2; foreach ($aCommands as $oCommand) { $sName = $oCommand->getName(); $sDescription = $oCommand->getDescription(); $iDescriptionOffset = $iOffset - strlen($sName); $oOutput->writeLn(sprintf(" %s %{$iDescriptionOffset}s # %s", $sName, ' ', $sDescription)); } }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { try { $sTimestamp = $this->_parseTimestamp(); } catch (oxConsoleException $oEx) { $oOutput->writeLn($oEx->getMessage()); return; } $oOutput->writeLn('Running migration scripts'); $oInput = $this->getInput(); $oDebugOutput = $oInput->hasOption(array('n', 'no-debug')) ? oxNew('oxNullOutput') : $oOutput; /** @var oxMigrationHandler $oMigrationHandler */ $oMigrationHandler = oxRegistry::get('oxMigrationHandler'); $oMigrationHandler->run($sTimestamp, $oDebugOutput); $oOutput->writeLn('Migration finished successfully'); }
/** * {@inheritdoc} */ public function help(oxIOutput $oOutput) { $oOutput->writeLn('Usage: module:activate [options] moduleid'); $oOutput->writeLn(); $oOutput->writeLn('This command imports shop config'); $oOutput->writeLn(); $oOutput->writeLn('Available options:'); $oOutput->writeLn(' -n, --no-debug No debug output'); $oOutput->writeLn(' -s, --shop Shop'); }
/** * 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); } $sMigrationFileName = oxMigrationQuery::getCurrentTimestamp() . '_' . strtolower($sMigrationName) . '.php'; $sMigrationFilePath = $sMigrationsDir . $sMigrationFileName; /** @var Smarty $oSmarty */ $oSmarty = oxRegistry::get('oxUtilsView')->getSmarty(); $oSmarty->assign('sMigrationName', $sMigrationName); $sContent = $oSmarty->fetch($sTemplatePath); file_put_contents($sMigrationFilePath, $sContent); $oOutput->writeLn("Sucessfully generated {$sMigrationFileName}"); }
/** * Output help text of command * * @param oxIOutput $oOutput */ public function help(oxIOutput $oOutput) { $oOutput->writeLn('Usage: g:migration <word> [<second_word>...]'); $oOutput->writeLn(); $oOutput->writeLn('Generates blank migration class.'); $oOutput->writeLn('Migration name depends on words you have written.'); $oOutput->writeLn(); $oOutput->writeLn('If no words were passed you will be asked to input them'); }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $oInput = $this->getInput(); $blAll = !$oInput->hasOption(array('s', 'smarty', 'f', 'files', 'o', 'oxcache')); $sTmpDir = $this->_appendDirectorySeparator(oxRegistry::getConfig()->getConfigParam('sCompileDir')); if (!is_dir($sTmpDir)) { $oOutput->writeLn('Seems that compile directory does not exist'); return; } $oOutput->writeLn('Clearing OXID cache...'); if (($blAll || $oInput->hasOption(array('o', 'oxcache'))) && class_exists('oxCache')) { oxRegistry::get('oxCache')->reset(false); } if ($blAll || $oInput->hasOption(array('s', 'smarty'))) { $this->_clearDirectory($sTmpDir . 'smarty'); } if ($blAll || $oInput->hasOption(array('f', 'files'))) { $this->_clearDirectory($sTmpDir, array('.htaccess', 'smarty')); } $oOutput->writeLn('Cache cleared successfully'); }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $oInput = $this->getInput(); if (oxRegistry::getConfig()->getEdition() == 'EE') { $oOutput->writeLn('Clearing OXID db and backend cache..'); /** @var oxCache $oCache */ $oCache = oxNew('oxcache'); $oCache->reset(false); $oOutput->writeLn('Oxid Cache cleared successfully'); } $sTmpDir = $this->_appendDirectorySeparator(oxRegistry::getConfig()->getConfigParam('sCompileDir')); if (!is_dir($sTmpDir)) { $oOutput->writeLn('Seems that compile directory does not exist'); } $oOutput->writeLn("Clearing OXID File cache ({$sTmpDir})..."); $this->_clearDirectory($sTmpDir . 'smarty'); if (!$oInput->hasOption(array('s', 'smarty'))) { // If there are no options for clearing smarty cache only $this->_clearDirectory($sTmpDir, array('.htaccess', 'smarty')); } $oOutput->writeLn('File Cache cleared successfully'); }
/** * Executes a DOWN Migration * * @param oxMigrationQuery $oQuery The query object that is being executed * @param oxIOutput $oOutput The output handler for the console output that might be generated * * @return bool */ protected function _goDown(oxMigrationQuery $oQuery, oxIOutput $oOutput = null) { if (!$this->isExecuted($oQuery)) { return false; } if ($oOutput) { $oOutput->writeLn(sprintf('[DEBUG] Migrating down %s %s', $oQuery->getTimestamp(), $oQuery->getClassName())); } $oQuery->down(); $this->setUnexecuted($oQuery); return true; }
/** * Build migration name from tokens * * @param array $aTokens * @param oxIOutput $oOutput * @return string */ protected function _buildCommandName(array $aTokens, oxIOutput $oOutput) { $sCommandName = ''; foreach ($aTokens as $sToken) { if (!$sToken) { continue; } $sCommandName .= ucfirst($sToken); } if (class_exists($sCommandName . 'Command')) { $sCommandName = ''; $oOutput->writeLn(); $oOutput->writeLn($sCommandName . 'Command already exists, choose different name.'); } return $sCommandName; }
/** * {@inheritdoc} */ public function execute(oxIOutput $oOutput) { $config = oxRegistry::getConfig(); if (count($this->getInput()->getArguments()) !== 5) { $oOutput->writeLn('wrong syntax!'); $oOutput->writeLn('Usage: import:oscommerce [hostname] [username] [password] [database]'); } $this->importerService = new OSCommerceImporterService(); $this->importerService->configureDatabase('osc', $this->getInput()->getArgument(1), $this->getInput()->getArgument(2), $this->getInput()->getArgument(3), $this->getInput()->getArgument(4)); $this->importerService->configureDatabase('oxid', $config->getConfigParam('dbHost'), $config->getConfigParam('dbUser'), $config->getConfigParam('dbPwd'), $config->getConfigParam('dbName')); if (!$this->importerService->isConnected()) { $oOutput->writeLn(''); $oOutput->writeLn('Connection to database failed!'); exit(1); } else { $settings = array(); if ($this->getInput()->hasOption('prefix')) { $settings['prefix'] = $this->getInput()->getOption('prefix'); } if ($this->getInput()->hasOption('strip-tags')) { $settings['strip-tags'] = true; } if ($this->getInput()->hasOption('delete-old-data')) { $settings['cleanup'] = true; $oOutput->writeLn('old data cleared...'); } if ($this->getInput()->hasOption('use-pics-in-desc')) { $settings['use-pics-in-desc'] = true; $oOutput->writeLn('importing product pictures from description'); } $this->importerService->setSettings($settings); $this->importerService->importProducts(); $oOutput->writeLn('products imported...'); $this->importerService->importCategories(); $oOutput->writeLn('categories imported...'); $this->importerService->importProductsToCategories(); $oOutput->writeLn('products to categories assigned...'); $this->importerService->importUsers(); $this->importerService->importAddresses(); $oOutput->writeLn('customers imported...'); $this->importerService->importAdministrators(); $oOutput->writeLn('administrators imported...'); $this->importerService->importProductDescriptionAndPictures(); $oOutput->writeLn('description imported'); } }
/** * Build scaffold object from user inputs * * @param oxIOutput $oOutput * * @return stdClass */ protected function _buildScaffold(oxIOutput $oOutput) { $oScaffold = new stdClass(); $oScaffold->sVendor = strtolower($this->_getUserInput('Vendor Prefix', true)); $blFirstRequest = true; do { if (!$blFirstRequest) { $oOutput->writeLn('Module path or id is taken with given title'); } else { $blFirstRequest = false; } $oScaffold->sModuleTitle = $this->_getUserInput('Module Title'); $oScaffold->sModuleName = str_replace(' ', '', ucwords($oScaffold->sModuleTitle)); $oScaffold->sModuleId = $oScaffold->sVendor . strtolower($oScaffold->sModuleName); } while (!$this->_modulePathAvailable($oScaffold->sVendor, $oScaffold->sModuleName) || !$this->_moduleIdAvailable($oScaffold->sModuleId)); $oScaffold->sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName); $oScaffold->sAuthor = $this->_getUserInput('Author', true); $oScaffold->sUrl = $this->_getUserInput('Url', true); $oScaffold->sEmail = $this->_getUserInput('Email', true); return $oScaffold; }