From 9e9c15be599b4a284d24759e860347ca75051e83 Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Tue, 9 Jul 2019 10:15:39 -0500 Subject: [PATCH 1/3] MAGECLOUD-3866: Warm up functionality does not work if no store with 'default' code --- .../Command/ConfigShowDefaultUrlCommand.php | 68 +++++++++++++++++++ etc/di.xml | 1 + 2 files changed, 69 insertions(+) create mode 100644 Console/Command/ConfigShowDefaultUrlCommand.php diff --git a/Console/Command/ConfigShowDefaultUrlCommand.php b/Console/Command/ConfigShowDefaultUrlCommand.php new file mode 100644 index 0000000..115cd07 --- /dev/null +++ b/Console/Command/ConfigShowDefaultUrlCommand.php @@ -0,0 +1,68 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + protected function configure() + { + $this->setName('config:show:default-url') + ->setDescription( + 'Shows base url for default store of default website' + ); + + parent::configure(); + } + + /** + * Returns base url for default store of default website + * + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + /** @var Store $store */ + $store = $this->storeManager->getDefaultStoreView(); + $output->write($store->getBaseUrl(UrlInterface::URL_TYPE_LINK, $store->isUrlSecure())); + + return Cli::RETURN_SUCCESS; + } catch (\Exception $e) { + $output->writeln(sprintf('%s', $e->getMessage())); + return Cli::RETURN_FAILURE; + } + } +} diff --git a/etc/di.xml b/etc/di.xml index 7c3b704..e531790 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -11,6 +11,7 @@ Magento\CloudComponents\Console\Command\ConfigShowStoreUrlCommand Magento\CloudComponents\Console\Command\ConfigShowEntityUrlsCommand + Magento\CloudComponents\Console\Command\ConfigShowDefaultUrlCommand From c452fba2614568d16692e3652285f683c457deee Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Tue, 9 Jul 2019 10:18:52 -0500 Subject: [PATCH 2/3] MAGECLOUD-3866: Warm up functionality does not work if no store with 'default' code --- Console/Command/ConfigShowDefaultUrlCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Console/Command/ConfigShowDefaultUrlCommand.php b/Console/Command/ConfigShowDefaultUrlCommand.php index 115cd07..6b9ba66 100644 --- a/Console/Command/ConfigShowDefaultUrlCommand.php +++ b/Console/Command/ConfigShowDefaultUrlCommand.php @@ -10,7 +10,6 @@ use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; From eb25d5ed9f11c938c73584ace493c9c5247176af Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Tue, 9 Jul 2019 13:14:06 -0500 Subject: [PATCH 3/3] MAGECLOUD-3866: Warm up functionality does not work if no store with 'default' code --- .../Command/ConfigShowDefaultUrlCommand.php | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Console/Command/ConfigShowDefaultUrlCommand.php b/Console/Command/ConfigShowDefaultUrlCommand.php index 6b9ba66..20c69be 100644 --- a/Console/Command/ConfigShowDefaultUrlCommand.php +++ b/Console/Command/ConfigShowDefaultUrlCommand.php @@ -26,9 +26,8 @@ class ConfigShowDefaultUrlCommand extends Command /** * @param StoreManagerInterface $storeManager */ - public function __construct( - StoreManagerInterface $storeManager - ) { + public function __construct(StoreManagerInterface $storeManager) + { parent::__construct(); $this->storeManager = $storeManager; } @@ -39,9 +38,7 @@ public function __construct( protected function configure() { $this->setName('config:show:default-url') - ->setDescription( - 'Shows base url for default store of default website' - ); + ->setDescription('Shows base url for default store of default website'); parent::configure(); } @@ -53,15 +50,10 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - try { - /** @var Store $store */ - $store = $this->storeManager->getDefaultStoreView(); - $output->write($store->getBaseUrl(UrlInterface::URL_TYPE_LINK, $store->isUrlSecure())); + /** @var Store $store */ + $store = $this->storeManager->getDefaultStoreView(); + $output->write($store->getBaseUrl(UrlInterface::URL_TYPE_LINK, $store->isUrlSecure())); - return Cli::RETURN_SUCCESS; - } catch (\Exception $e) { - $output->writeln(sprintf('%s', $e->getMessage())); - return Cli::RETURN_FAILURE; - } + return Cli::RETURN_SUCCESS; } }