/** * @return ViewModel */ public function indexAction() { $this->maintenanceMode->set(false); $view = new ViewModel(); $view->setTerminal(true); return $view; }
public function testMaintenanceModeOff() { $this->flagDir->expects($this->at(0))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME)->will($this->returnValue(true)); $this->flagDir->expects($this->at(1))->method('delete')->with(MaintenanceMode::FLAG_FILENAME)->will($this->returnValue(false)); $this->flagDir->expects($this->at(2))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME)->will($this->returnValue(false)); $this->assertFalse($this->model->set(false)); $this->assertFalse($this->model->isOn()); }
/** * Puts store in maintenance mode * * @return JsonModel */ public function indexAction() { try { $this->maintenanceMode->set(true); return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS]); } catch (\Exception $e) { return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'error' => $e->getMessage()]); } }
/** * Puts store in maintenance mode * * @return JsonModel */ public function indexAction() { try { $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); $action = isset($params['disable']) && $params['disable'] ? false : true; $this->maintenanceMode->set($action); return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS]); } catch (\Exception $e) { return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'error' => $e->getMessage()]); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $addresses = $input->getOption(self::INPUT_KEY_IP); $this->maintenanceMode->set($this->isEnable()); $output->writeln($this->getDisplayString()); if (!empty($addresses)) { $addresses = implode(',', $addresses); $addresses = 'none' == $addresses ? '' : $addresses; $this->maintenanceMode->setAddresses($addresses); $output->writeln('<info>Set exempt IP-addresses: ' . (implode(', ', $this->maintenanceMode->getAddressInfo()) ?: 'none') . '</info>'); } }
/** * Create Backup * * @return $this */ public function execute() { if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) { return $this; } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->set(true); } $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE); $this->_errors = []; try { $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir()); $this->_coreRegistry->register('backup_manager', $backupManager); if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) { $backupManager->setRootDir($this->_filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath())->addIgnorePaths($this->_backupData->getBackupIgnorePaths()); } $backupManager->create(); $message = $this->_backupData->getCreateSuccessMessageByType($type); $this->_logger->info($message); } catch (\Exception $e) { $this->_errors[] = $e->getMessage(); $this->_errors[] = $e->getTrace(); $this->_logger->info($e->getMessage()); $this->_logger->critical($e); } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { $this->maintenanceMode->set(false); } return $this; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$this->deploymentConfig->isAvailable() && ($input->getOption(self::INPUT_KEY_MEDIA_BACKUP_FILE) || $input->getOption(self::INPUT_KEY_DB_BACKUP_FILE))) { $output->writeln("<info>No information is available: the Magento application is not installed.</info>"); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } $returnValue = \Magento\Framework\Console\Cli::RETURN_SUCCESS; try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('<info>You are about to remove current code and/or database tables. Are you sure?[y/N]<info>', false); if (!$helper->ask($input, $output, $question) && $input->isInteractive()) { return \Magento\Framework\Console\Cli::RETURN_FAILURE; } $this->doRollback($input, $output); $output->writeln('<info>Please set file permission of bin/magento to executable</info>'); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); // we must have an exit code higher than zero to indicate something was wrong $returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE; } finally { $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } return $returnValue; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $messages = []; $themePaths = $input->getArgument(self::INPUT_KEY_THEMES); $messages = array_merge($messages, $this->validate($themePaths)); if (!empty($messages)) { $output->writeln($messages); return; } $messages = array_merge($messages, $this->themeValidator->validateIsThemeInUse($themePaths), $this->themeDependencyChecker->checkChildTheme($themePaths), $this->checkDependencies($themePaths)); if (!empty($messages)) { $output->writeln('<error>Unable to uninstall. Please resolve the following issues:</error>' . PHP_EOL . implode(PHP_EOL, $messages)); return; } try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); if ($input->getOption(self::INPUT_KEY_BACKUP_CODE)) { $time = time(); $codeBackup = $this->backupRollbackFactory->create($output); $codeBackup->codeBackup($time); } $this->themeUninstaller->uninstallRegistry($output, $themePaths); $this->themeUninstaller->uninstallCode($output, $themePaths); $this->cleanup($input, $output); $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>'); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$this->deploymentConfig->isAvailable() && ($input->getOption(self::INPUT_KEY_MEDIA) || $input->getOption(self::INPUT_KEY_DB))) { $output->writeln("<info>No information is available: the Magento application is not installed.</info>"); return; } try { $inputOptionProvided = false; $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); $time = time(); $backupHandler = $this->backupRollbackFactory->create($output); if ($input->getOption(self::INPUT_KEY_CODE)) { $backupHandler->codeBackup($time); $inputOptionProvided = true; } if ($input->getOption(self::INPUT_KEY_MEDIA)) { $backupHandler->codeBackup($time, Factory::TYPE_MEDIA); $inputOptionProvided = true; } if ($input->getOption(self::INPUT_KEY_DB)) { $backupHandler->dbBackup($time); $inputOptionProvided = true; } if (!$inputOptionProvided) { throw new \InvalidArgumentException('Not enough information provided to take backup.'); } } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } finally { $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $addresses = $input->getOption(self::INPUT_KEY_IP); $messages = $this->validate($addresses); if (!empty($messages)) { $output->writeln('<error>' . implode('</error>' . PHP_EOL . '<error>', $messages)); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } $this->maintenanceMode->set($this->isEnable()); $output->writeln($this->getDisplayString()); if (!empty($addresses)) { $addresses = implode(',', $addresses); $addresses = 'none' == $addresses ? '' : $addresses; $this->maintenanceMode->setAddresses($addresses); $output->writeln('<info>Set exempt IP-addresses: ' . (implode(', ', $this->maintenanceMode->getAddressInfo()) ?: 'none') . '</info>'); } }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$this->deploymentConfig->isAvailable()) { $output->writeln('<error>You cannot run this command because the Magento application is not installed.</error>'); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } $modules = $input->getArgument(self::INPUT_KEY_MODULES); // validate modules input $messages = $this->validate($modules); if (!empty($messages)) { $output->writeln($messages); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } // check dependencies $dependencyMessages = $this->checkDependencies($modules); if (!empty($dependencyMessages)) { $output->writeln($dependencyMessages); // we must have an exit code higher than zero to indicate something was wrong return \Magento\Framework\Console\Cli::RETURN_FAILURE; } $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('You are about to remove code and/or database tables. Are you sure?[y/N]', false); if (!$helper->ask($input, $output, $question) && $input->isInteractive()) { return \Magento\Framework\Console\Cli::RETURN_FAILURE; } try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); $this->takeBackup($input, $output); $dbBackupOption = $input->getOption(self::INPUT_KEY_BACKUP_DB); if ($input->getOption(self::INPUT_KEY_REMOVE_DATA)) { $this->removeData($modules, $output, $dbBackupOption); } else { if (!empty($this->collector->collectUninstall())) { $question = new ConfirmationQuestion('You are about to remove a module(s) that might have database data. ' . 'Do you want to remove the data from database?[y/N]', false); if ($helper->ask($input, $output, $question) || !$input->isInteractive()) { $this->removeData($modules, $output, $dbBackupOption); } } else { $output->writeln('<info>You are about to remove a module(s) that might have database data. ' . 'Remove the database data manually after uninstalling, if desired.</info>'); } } $this->moduleRegistryUninstaller->removeModulesFromDb($output, $modules); $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($output, $modules); $this->moduleUninstaller->uninstallCode($output, $modules); $this->cleanup($input, $output); $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>'); return \Magento\Framework\Console\Cli::RETURN_FAILURE; } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $themePaths = $input->getArgument(self::INPUT_KEY_THEMES); $validationMessages = $this->validate($themePaths); if (!empty($validationMessages)) { $output->writeln($validationMessages); return; } $isThemeInUseMessages = $this->themeValidator->validateIsThemeInUse($themePaths); if (!empty($isThemeInUseMessages)) { $output->writeln($isThemeInUseMessages); return; } $childThemeCheckMessages = $this->checkChildTheme($themePaths); if (!empty($childThemeCheckMessages)) { $output->writeln($childThemeCheckMessages); return; } $dependencyMessages = $this->checkDependencies($themePaths); if (!empty($dependencyMessages)) { $output->writeln($dependencyMessages); return; } try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); if ($input->getOption(self::INPUT_KEY_BACKUP_CODE)) { $time = time(); $codeBackup = $this->backupRollbackFactory->create($output); $codeBackup->codeBackup($time); } $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from database'); $this->removeFromDb($themePaths); $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from Magento codebase'); $themePackages = []; foreach ($themePaths as $themePath) { $themePackages[] = $this->getPackageName($themePath); } $this->remove->remove($themePackages); $this->cleanup($input, $output); $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>'); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$this->deploymentConfig->isAvailable() && ($input->getOption(self::INPUT_KEY_MEDIA_BACKUP_FILE) || $input->getOption(self::INPUT_KEY_DB_BACKUP_FILE))) { $output->writeln("<info>No information is available: the Magento application is not installed.</info>"); return; } try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('<info>You are about to remove current code and/or database tables. Are you sure?[y/N]<info>', false); if (!$helper->ask($input, $output, $question) && $input->isInteractive()) { return; } $this->doRollback($input, $output); $output->writeln('<info>Please set file permission of bin/magento to executable</info>'); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } finally { $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } }
/** * Enables or disables maintenance mode for Magento application * * @param int $value * @return void * * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback. */ private function setMaintenanceMode($value) { $this->maintenanceMode->set($value); }