1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\System\Store\Config; |
4
|
|
|
|
5
|
|
|
use N98\Magento\Command\AbstractMagentoCommand; |
6
|
|
|
use N98\Util\Console\Helper\Table\Renderer\RendererFactory; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
|
11
|
|
|
class BaseUrlListCommand extends AbstractMagentoCommand |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var \Magento\Framework\Store\StoreManagerInterface |
15
|
|
|
*/ |
16
|
|
|
protected $storeManager; |
17
|
|
|
|
18
|
|
|
protected function configure() |
19
|
|
|
{ |
20
|
|
|
$this |
21
|
|
|
->setName('sys:store:config:base-url:list') |
22
|
|
|
->setDescription('Lists all base urls') |
23
|
|
|
->addOption( |
24
|
|
|
'format', |
25
|
|
|
null, |
26
|
|
|
InputOption::VALUE_OPTIONAL, |
27
|
|
|
'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' |
28
|
|
|
) |
29
|
|
|
; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param \Magento\Store\Model\StoreManagerInterface $storeManager |
34
|
|
|
*/ |
35
|
|
|
public function inject(\Magento\Store\Model\StoreManagerInterface $storeManager) |
36
|
|
|
{ |
37
|
|
|
$this->storeManager = $storeManager; |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param InputInterface $input |
42
|
|
|
* @param OutputInterface $output |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
46
|
|
|
{ |
47
|
|
|
$this->detectMagento($output, true); |
48
|
|
|
|
49
|
|
|
if (!$input->getOption('format')) { |
50
|
|
|
$this->writeSection($output, 'Magento Stores - Base URLs'); |
51
|
|
|
} |
52
|
|
|
$this->initMagento(); |
53
|
|
|
|
54
|
|
|
foreach ($this->storeManager->getStores() as $store) { |
55
|
|
|
$table[$store->getId()] = array( |
|
|
|
|
56
|
|
|
$store->getId(), |
57
|
|
|
$store->getCode(), |
58
|
|
|
$store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB), |
59
|
|
|
$store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true), |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
ksort($table); |
64
|
|
|
$this->getHelper('table') |
65
|
|
|
->setHeaders(array('id', 'code', 'unsecure_baseurl', 'secure_baseurl')) |
66
|
|
|
->renderByFormat($output, $table, $input->getOption('format')); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..