5 * Contains \Drupal\Console\Command\Module\DebugCommand.
8 namespace Drupal\Console\Command\Module;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Symfony\Component\Console\Command\Command;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Core\Style\DrupalStyle;
17 use Drupal\Console\Utils\Site;
18 use GuzzleHttp\Client;
19 use Drupal\Console\Core\Utils\ConfigurationManager;
21 class DebugCommand extends Command
26 * @var ConfigurationManager
28 protected $configurationManager;
36 * DebugCommand constructor.
38 * @param Client $httpClient
41 protected $httpClient;
44 * ChainDebugCommand constructor.
46 * @param ConfigurationManager $configurationManager
49 public function __construct(
50 ConfigurationManager $configurationManager,
54 $this->configurationManager = $configurationManager;
56 $this->httpClient = $httpClient;
57 parent::__construct();
60 protected function configure()
63 ->setName('module:debug')
64 ->setDescription($this->trans('commands.module.debug.description'))
67 InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
68 $this->trans('commands.module.debug.module')
73 InputOption::VALUE_OPTIONAL,
74 $this->trans('commands.module.debug.options.status')
79 InputOption::VALUE_OPTIONAL,
80 $this->trans('commands.module.debug.options.type')
84 protected function execute(InputInterface $input, OutputInterface $output)
86 $io = new DrupalStyle($input, $output);
88 $this->site->loadLegacyFile('/core/modules/system/system.module');
90 $status = strtolower($input->getOption('status'));
91 $type = strtolower($input->getOption('type'));
92 $modules = strtolower($input->getArgument('module'));
95 $config = $this->configurationManager->getConfiguration();
96 $repo = $config->get('application.composer.repositories.default');
98 foreach ($modules as $module) {
100 '%s/packages/drupal/%s.json',
101 $config->get('application.composer.packages.default'),
106 $data = $this->httpClient->getUrlAsJson($repo . $url);
107 } catch (\Exception $e) {
110 $this->trans('commands.module.debug.messages.no-results'),
119 '<info>'.$data->package->name.'</info>'
125 $data->package->description
129 '<comment>'.$this->trans('commands.module.debug.messages.total-downloads').'</comment>',
130 $data->package->downloads->total
134 '<comment>'.$this->trans('commands.module.debug.messages.total-monthly').'</comment>',
135 $data->package->downloads->monthly
139 '<comment>'.$this->trans('commands.module.debug.messages.total-daily').'</comment>',
140 $data->package->downloads->daily
143 $io->table($tableHeader, $tableRows, 'compact');
148 if ($status == 'installed') {
150 } elseif ($status == 'uninstalled') {
156 if ($type == 'core') {
158 } elseif ($type == 'no-core') {
165 $this->trans('commands.module.debug.messages.id'),
166 $this->trans('commands.module.debug.messages.name'),
167 $this->trans('commands.module.debug.messages.package'),
168 $this->trans('commands.module.debug.messages.version'),
169 $this->trans('commands.module.debug.messages.schema-version'),
170 $this->trans('commands.module.debug.messages.status'),
171 $this->trans('commands.module.debug.messages.origin'),
175 $modules = system_rebuild_module_data();
176 foreach ($modules as $module_id => $module) {
177 if ($status >= 0 && $status != $module->status) {
181 if ($type !== null && $type !== $module->origin) {
185 $module_status = ($module->status) ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled');
186 $module_origin = ($module->origin) ? $module->origin : 'no core';
187 $schema_version = (drupal_get_installed_schema_version($module_id)!= -1?drupal_get_installed_schema_version($module_id): '');
191 $module->info['name'],
192 $module->info['package'],
193 $module->info['version'],
200 $io->table($tableHeader, $tableRows, 'compact');