10 use Symfony\Component\Console\Command\Command;
11 use Symfony\Component\Console\Exception\InvalidArgumentException;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Symfony\Component\Console\Input\InputArgument;
15 use Symfony\Component\Console\Helper\Table;
32 private $diInformation;
40 $this->diInformation = $diInformation;
41 parent::__construct();
50 $this->setName(self::COMMAND_NAME)
51 ->setDescription(
'Provides information on Dependency Injection configuration for the Command.')
53 new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED,
'Class name')
68 $preference = $this->diInformation->getPreference(
$className);
70 $output->writeln(sprintf(
'Preference: %s', $preference));
83 $output->writeln(
"Constructor Parameters:");
84 $paramsTable =
new Table(
$output);
86 ->setHeaders([
'Name',
'Requested Type',
'Configured Value']);
87 $parameters = $this->diInformation->getParameters(
$className);
88 $paramsTableArray = [];
89 foreach ($parameters as $parameterRow) {
90 if (is_array($parameterRow[2])) {
91 $parameterRow[2] = json_encode($parameterRow[2], JSON_PRETTY_PRINT);
93 $paramsTableArray[] = $parameterRow;
95 $paramsTable->setRows($paramsTableArray);
96 $output->writeln($paramsTable->render());
108 $virtualTypes = $this->diInformation->getVirtualTypes(
$className);
109 if (!empty($virtualTypes)) {
111 $output->writeln(
"Virtual Types:");
112 foreach ($this->diInformation->getVirtualTypes(
$className) as $virtualType) {
113 $output->writeln(
' ' . $virtualType);
130 $plugins = $this->diInformation->getPlugins(
$className);
132 foreach ($plugins as
$type => $plugin) {
133 foreach ($plugin as $instance => $pluginMethods) {
134 foreach ($pluginMethods as $pluginMethod) {
135 $parameters[] = [$instance, $pluginMethod,
$type];
142 ->setHeaders([
'Plugin',
'Method',
'Type'])
143 ->setRows($parameters);
154 $className = $input->getArgument(self::CLASS_NAME);
157 $output->writeln(sprintf(
'DI configuration for the class %s in the GLOBAL area',
$className));
159 if ($this->diInformation->isVirtualType(
$className)) {
161 sprintf(
'It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase(
$className))
166 $preference = $this->diInformation->getPreference(
$className);
167 $this->printVirtualTypes($preference,
$output);
169 $this->printPlugins($preference,
$output,
'Plugins for the Preference:');
171 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
__construct(Information $diInformation)
execute(InputInterface $input, OutputInterface $output)