From 825d24a5a38f218fa14a9a05982120bc65b17555 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 19 Jan 2024 16:02:11 +0200 Subject: [PATCH] Added swissup:info:virtualfix command --- Console/Command/InfoCommand.php | 9 ++-- Console/Command/InfoVirtualfixCommand.php | 53 +++++++++++++++++++++++ etc/di.xml | 2 +- 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 Console/Command/InfoVirtualfixCommand.php diff --git a/Console/Command/InfoCommand.php b/Console/Command/InfoCommand.php index aace90e..f4bf15b 100644 --- a/Console/Command/InfoCommand.php +++ b/Console/Command/InfoCommand.php @@ -15,7 +15,6 @@ class InfoCommand extends Command { - /** * @var \Magento\Framework\App\State */ @@ -32,7 +31,6 @@ public function __construct(State $appState) $this->appState = $appState; } - protected function configure() { $this->setName('swissup:info') @@ -45,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'php_version' => 'php -v | head -n 1 && whereis php', 'magento_version' => 'php bin/magento --version', 'composer_version' => 'composer --version && whereis composer', - 'nginx_apache_user' => 'whoami', + 'nginx_user' => 'whoami', ]; $folderPaths = [ @@ -56,7 +54,6 @@ protected function execute(InputInterface $input, OutputInterface $output) ]; try { - // Environment Check commands foreach ($commands as $key => $value) { @@ -69,17 +66,17 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->checkFolder($folderPath, $output); } + $output->writeln('_____________________________'); + // Output Magento 2 "theme" table data $this->outputMagentoThemeData($input, $output); - return Command::SUCCESS; } catch (\Exception $e) { $output->writeln("Error: " . $e->getMessage() . ""); return Command::FAILURE; } - return Command::SUCCESS; } diff --git a/Console/Command/InfoVirtualfixCommand.php b/Console/Command/InfoVirtualfixCommand.php new file mode 100644 index 0000000..47ddc38 --- /dev/null +++ b/Console/Command/InfoVirtualfixCommand.php @@ -0,0 +1,53 @@ +collectionFactory = $collectionFactory; + $this->logger = $logger; + } + + protected function configure() + { + $this->setName('swissup:info:virtualfix') + ->setDescription('Fix Virtual themes'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $virtualThemes = $this->collectionFactory->create()->addFieldToFilter('type', 1); + foreach ($virtualThemes as $theme) { + $theme->setType(0)->save(); + } + + $this->logger->info('Virtual themes fixed successfully.'); + $output->writeln('Executing swissup:info:virtualfix command...'); + $output->writeln('Virtual fix operations completed.'); + + return Command::SUCCESS; + } catch (\Exception $e) { + $this->logger->error('Error fixing virtual themes: ' . $e->getMessage()); + $output->writeln('Error fixing virtual themes: ' . $e->getMessage() . ''); + + return Command::FAILURE; + } + } +} diff --git a/etc/di.xml b/etc/di.xml index 17ac9ba..948e599 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -4,7 +4,7 @@ Swissup\Diagnostic\Console\Command\InfoCommand - + Swissup\Diagnostic\Console\Command\InfoVirtualFixCommand