Skip to content

Commit 5499165

Browse files
oshmyheliukBaDos
authored andcommitted
MAGECLOUD-3866: Warm up functionality does not work if no store with 'default' code (#5)
1 parent 30d47bf commit 5499165

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CloudComponents\Console\Command;
7+
8+
use Magento\Framework\Console\Cli;
9+
use Magento\Framework\UrlInterface;
10+
use Magento\Store\Model\Store;
11+
use Magento\Store\Model\StoreManagerInterface;
12+
use Symfony\Component\Console\Command\Command;
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
/**
17+
* Command for getting url for default store of default website.
18+
*/
19+
class ConfigShowDefaultUrlCommand extends Command
20+
{
21+
/**
22+
* @var StoreManagerInterface
23+
*/
24+
private $storeManager;
25+
26+
/**
27+
* @param StoreManagerInterface $storeManager
28+
*/
29+
public function __construct(StoreManagerInterface $storeManager)
30+
{
31+
parent::__construct();
32+
$this->storeManager = $storeManager;
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
protected function configure()
39+
{
40+
$this->setName('config:show:default-url')
41+
->setDescription('Shows base url for default store of default website');
42+
43+
parent::configure();
44+
}
45+
46+
/**
47+
* Returns base url for default store of default website
48+
*
49+
* {@inheritdoc}
50+
*/
51+
protected function execute(InputInterface $input, OutputInterface $output)
52+
{
53+
/** @var Store $store */
54+
$store = $this->storeManager->getDefaultStoreView();
55+
$output->write($store->getBaseUrl(UrlInterface::URL_TYPE_LINK, $store->isUrlSecure()));
56+
57+
return Cli::RETURN_SUCCESS;
58+
}
59+
}

etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<argument name="commands" xsi:type="array">
1212
<item name="configShowStoreUrlCommand" xsi:type="object">Magento\CloudComponents\Console\Command\ConfigShowStoreUrlCommand</item>
1313
<item name="configShowEntityUrlsCommand" xsi:type="object">Magento\CloudComponents\Console\Command\ConfigShowEntityUrlsCommand</item>
14+
<item name="ConfigShowDefaultUrlCommand" xsi:type="object">Magento\CloudComponents\Console\Command\ConfigShowDefaultUrlCommand</item>
1415
</argument>
1516
</arguments>
1617
</type>

0 commit comments

Comments
 (0)