|
| 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 | +} |
0 commit comments