5 * Contains \Drupal\Console\Command\Debug\ModuleCommand.
8 namespace Drupal\Console\Command\Debug;
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 Drupal\Console\Core\Command\Command;
15 use Drupal\Console\Utils\Site;
16 use GuzzleHttp\Client;
17 use Drupal\Console\Core\Utils\ConfigurationManager;
19 class ModuleCommand extends Command
22 * @var ConfigurationManager
24 protected $configurationManager;
32 * DebugCommand constructor.
34 * @param Client $httpClient
37 protected $httpClient;
40 * ChainDebugCommand constructor.
42 * @param ConfigurationManager $configurationManager
45 public function __construct(
46 ConfigurationManager $configurationManager,
50 $this->configurationManager = $configurationManager;
52 $this->httpClient = $httpClient;
53 parent::__construct();
56 protected function configure()
59 ->setName('debug:module')
60 ->setDescription($this->trans('commands.debug.module.description'))
63 InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
64 $this->trans('commands.debug.module.module')
69 InputOption::VALUE_OPTIONAL,
70 $this->trans('commands.debug.module.options.status')
75 InputOption::VALUE_OPTIONAL,
76 $this->trans('commands.debug.module.options.type')
81 protected function execute(InputInterface $input, OutputInterface $output)
83 $this->site->loadLegacyFile('/core/modules/system/system.module');
85 $status = strtolower($input->getOption('status'));
86 $type = strtolower($input->getOption('type'));
87 $modules = strtolower($input->getArgument('module'));
90 $config = $this->configurationManager->getConfiguration();
91 $repo = $config->get('application.composer.repositories.default');
93 foreach ($modules as $module) {
95 '%s/packages/drupal/%s.json',
96 $config->get('application.composer.packages.default'),
101 $data = $this->httpClient->getUrlAsJson($repo . $url);
102 } catch (\Exception $e) {
103 $this->getIo()->error(
105 $this->trans('commands.debug.module.messages.no-results'),
114 '<info>'.$data->package->name.'</info>'
120 $data->package->description
124 '<comment>'.$this->trans('commands.debug.module.messages.total-downloads').'</comment>',
125 $data->package->downloads->total
129 '<comment>'.$this->trans('commands.debug.module.messages.total-monthly').'</comment>',
130 $data->package->downloads->monthly
134 '<comment>'.$this->trans('commands.debug.module.messages.total-daily').'</comment>',
135 $data->package->downloads->daily
138 $this->getIo()->table($tableHeader, $tableRows, 'compact');
143 if ($status == 'installed') {
145 } elseif ($status == 'uninstalled') {
151 if ($type == 'core') {
153 } elseif ($type == 'no-core') {
160 $this->trans('commands.debug.module.messages.id'),
161 $this->trans('commands.debug.module.messages.name'),
162 $this->trans('commands.debug.module.messages.package'),
163 $this->trans('commands.debug.module.messages.version'),
164 $this->trans('commands.debug.module.messages.schema-version'),
165 $this->trans('commands.debug.module.messages.status'),
166 $this->trans('commands.debug.module.messages.origin'),
170 $modules = system_rebuild_module_data();
171 foreach ($modules as $module_id => $module) {
172 if ($status >= 0 && $status != $module->status) {
176 if ($type !== null && $type !== $module->origin) {
180 $module_status = ($module->status) ? $this->trans('commands.debug.module.messages.installed') : $this->trans('commands.debug.module.messages.uninstalled');
181 $module_origin = ($module->origin) ? $module->origin : 'no core';
182 $schema_version = (drupal_get_installed_schema_version($module_id)!= -1?drupal_get_installed_schema_version($module_id): '');
186 $module->info['name'],
187 $module->info['package'],
188 $module->info['version'],
195 $this->getIo()->table($tableHeader, $tableRows, 'compact');