本文整理汇总了PHP中Magento\Framework\App\DeploymentConfig::isAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP DeploymentConfig::isAvailable方法的具体用法?PHP DeploymentConfig::isAvailable怎么用?PHP DeploymentConfig::isAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\DeploymentConfig
的用法示例。
在下文中一共展示了DeploymentConfig::isAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@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);
}
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>No information is available: the Magento application is not installed.</info>");
return;
}
/** @var DbVersionInfo $dbVersionInfo */
$dbVersionInfo = $this->objectManagerProvider->get()->get('Magento\\Framework\\Module\\DbVersionInfo');
$outdated = $dbVersionInfo->getDbVersionErrors();
if (!empty($outdated)) {
$output->writeln("<info>The module code base doesn't match the DB schema and data.</info>");
$versionParser = new VersionParser();
$codebaseUpdateNeeded = false;
foreach ($outdated as $row) {
if (!$codebaseUpdateNeeded && $row[DbVersionInfo::KEY_CURRENT] !== 'none') {
// check if module code base update is needed
$currentVersion = $versionParser->parseConstraints($row[DbVersionInfo::KEY_CURRENT]);
$requiredVersion = $versionParser->parseConstraints('>' . $row[DbVersionInfo::KEY_REQUIRED]);
if ($requiredVersion->matches($currentVersion)) {
$codebaseUpdateNeeded = true;
}
}
$output->writeln(sprintf("<info>%20s %10s: %11s -> %-11s</info>", $row[DbVersionInfo::KEY_MODULE], $row[DbVersionInfo::KEY_TYPE], $row[DbVersionInfo::KEY_CURRENT], $row[DbVersionInfo::KEY_REQUIRED]));
}
if ($codebaseUpdateNeeded) {
$output->writeln('<info>Some modules use code versions newer or older than the database. ' . "First update the module code, then run 'setup:upgrade'.</info>");
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
} else {
$output->writeln("<info>Run 'setup:upgrade' to update your DB schema and data.</info>");
}
} else {
$output->writeln('<info>All modules are up to date.</info>');
}
}
示例3: execute
/**
* {@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;
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$notification = 'setup-cron: Please check var/log/update.log for execution summary.';
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln($notification);
$this->status->add('Magento is not installed.', \Psr\Log\LogLevel::INFO);
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
}
if (!$this->checkRun()) {
$output->writeln($notification);
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
try {
$this->status->toggleUpdateInProgress();
} catch (\RuntimeException $e) {
$this->status->add($e->getMessage(), \Psr\Log\LogLevel::ERROR);
$output->writeln($notification);
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$returnCode = $this->executeJobsFromQueue();
if ($returnCode != \Magento\Framework\Console\Cli::RETURN_SUCCESS) {
$output->writeln($notification);
}
return $returnCode;
}
示例5: testNotAvailableThenAvailable
public function testNotAvailableThenAvailable()
{
$this->reader->expects($this->at(0))->method('load')->willReturn([]);
$this->reader->expects($this->at(1))->method('load')->willReturn([ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE => 1]);
$object = new DeploymentConfig($this->reader);
$this->assertFalse($object->isAvailable());
$this->assertTrue($object->isAvailable());
}
示例6: testNotAvailableThenAvailable
public function testNotAvailableThenAvailable()
{
$this->reader->expects($this->at(0))->method('load')->willReturn([]);
$this->reader->expects($this->at(1))->method('load')->willReturn(['a' => 1]);
$object = new DeploymentConfig($this->reader);
$this->assertFalse($object->isAvailable());
$this->assertTrue($object->isAvailable());
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>Store settings can't be saved because the Magento application is not installed.</info>");
return;
}
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->installUserConfig($input->getOptions());
}
示例8: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>No information is available: the application is not installed.</info>");
return;
}
$installer = $this->installFactory->create(new ConsoleLogger($output));
$installer->installSchema();
}
示例9: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$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;
}
$installer = $this->installFactory->create(new ConsoleLogger($output));
$installer->installDataFixtures();
}
示例10: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>Store settings can't be saved because 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;
}
$errors = $this->validate($input);
if ($errors) {
$output->writeln($errors);
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->installUserConfig($input->getOptions());
}
示例11: checkEnvironment
/**
* Checks that application is installed and DI resources are cleared
*
* @return string[]
*/
private function checkEnvironment()
{
$messages = [];
if (!$this->deploymentConfig->isAvailable()) {
$messages[] = 'You cannot run this command because the Magento application is not installed.';
}
return $messages;
}
示例12: execute
/**
* {@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;
}
}
示例13: checkEnvironment
/**
* Checks that application is installed and DI resources are cleared
*
* @return string[]
*/
private function checkEnvironment()
{
$messages = [];
if (!$this->deploymentConfig->isAvailable()) {
$messages[] = 'You cannot run this command because the Magento application is not installed.';
}
/**
* By the time the command is able to execute, the Object Management configuration is already contaminated
* by old config info, and it's too late to just clear the files in code.
*
* TODO: reconfigure OM in runtime so DI resources can be cleared after command launches
*
*/
$path = $this->directoryList->getPath(DirectoryList::DI);
if ($this->fileDriver->isExists($path)) {
$messages[] = "DI configuration must be cleared before running compiler. Please delete '{$path}'.";
}
return $messages;
}
示例14: __construct
/**
* @param ServiceLocatorInterface $serviceLocator
* @param DeploymentConfig $deploymentConfig
*/
public function __construct(ServiceLocatorInterface $serviceLocator, DeploymentConfig $deploymentConfig)
{
if ($deploymentConfig->isAvailable()) {
$this->navStates = $serviceLocator->get('config')[self::NAV_UPDATER];
$this->navType = self::NAV_UPDATER;
$this->titles = $serviceLocator->get('config')[self::NAV_UPDATER . 'Titles'];
} else {
$this->navStates = $serviceLocator->get('config')[self::NAV_INSTALLER];
$this->navType = self::NAV_INSTALLER;
$this->titles = $serviceLocator->get('config')[self::NAV_INSTALLER . 'Titles'];
}
}
示例15: execute
/**
* {@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);
}
}