1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Config\Data; |
4
|
|
|
|
5
|
|
|
use Magento\Framework\ObjectManager\ConfigLoaderInterface; |
6
|
|
|
use N98\Magento\Command\AbstractMagentoCommand; |
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
use Symfony\Component\VarDumper\Cloner\VarCloner; |
12
|
|
|
use Symfony\Component\VarDumper\Dumper\CliDumper; |
13
|
|
|
|
14
|
|
|
class DiCommand extends AbstractMagentoCommand |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var \Magento\Framework\App\ProductMetadataInterface |
18
|
|
|
*/ |
19
|
|
|
private $productMetadata; |
|
|
|
|
20
|
|
|
|
21
|
|
|
protected function configure() |
22
|
|
|
{ |
23
|
|
|
$this |
24
|
|
|
->setName('config:data:di') |
25
|
|
|
->addArgument('type', InputArgument::OPTIONAL, 'Type (class)') |
26
|
|
|
->addOption( |
27
|
|
|
'scope', |
28
|
|
|
's', |
29
|
|
|
InputOption::VALUE_OPTIONAL, |
30
|
|
|
'Config scope (global, adminhtml, frontend, webapi_rest, webapi_soap, ...)', |
31
|
|
|
'global' |
32
|
|
|
) |
33
|
|
|
->setDescription('Dump dependency injection config') |
34
|
|
|
; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
39
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
40
|
|
|
* |
41
|
|
|
* @return int|void |
42
|
|
|
*/ |
43
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
44
|
|
|
{ |
45
|
|
|
$this->detectMagento($output, true); |
46
|
|
|
|
47
|
|
|
if (!$this->initMagento()) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** @var ConfigLoaderInterface $configLoader */ |
52
|
|
|
$configLoader = $this->getObjectManager()->get(ConfigLoaderInterface::class); |
53
|
|
|
$configDataPrimary = $configLoader->load('primary'); |
54
|
|
|
$configDataScope = $configLoader->load($input->getOption('scope')); |
55
|
|
|
|
56
|
|
|
$configData = array_merge_recursive($configDataPrimary, $configDataScope); |
57
|
|
|
|
58
|
|
|
$cloner = new VarCloner(); |
59
|
|
|
$cloner->setMaxItems(-1); |
60
|
|
|
$cloner->setMaxString(-1); |
61
|
|
|
$dumper = new CliDumper(); |
62
|
|
|
|
63
|
|
|
if ($input->getArgument('type')) { |
64
|
|
|
$config = []; |
65
|
|
|
|
66
|
|
|
$normalizedKey = ltrim($input->getArgument('type'), '\\'); |
67
|
|
|
if (isset($configData[$normalizedKey])) { |
68
|
|
|
$config[$normalizedKey] = $configData[$normalizedKey]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if (isset($configData['preferences'][$normalizedKey])) { |
72
|
|
|
$config['preferences'] = $configData['preferences'][$normalizedKey]; |
73
|
|
|
} |
74
|
|
|
} else { |
75
|
|
|
$config = $configData; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$dumpContent = $dumper->dump($cloner->cloneVar($config), true); |
|
|
|
|
79
|
|
|
|
80
|
|
|
$output->write($dumpContent); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.