X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FModule%2FDebugCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FModule%2FDebugCommand.php;h=8864c8c051b05c2ce7f90f0a96a3213d4eebe825;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Module/DebugCommand.php b/vendor/drupal/console/src/Command/Module/DebugCommand.php new file mode 100644 index 000000000..8864c8c05 --- /dev/null +++ b/vendor/drupal/console/src/Command/Module/DebugCommand.php @@ -0,0 +1,202 @@ +configurationManager = $configurationManager; + $this->site = $site; + $this->httpClient = $httpClient; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('module:debug') + ->setDescription($this->trans('commands.module.debug.description')) + ->addArgument( + 'module', + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + $this->trans('commands.module.debug.module') + ) + ->addOption( + 'status', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.module.debug.options.status') + ) + ->addOption( + 'type', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.module.debug.options.type') + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $this->site->loadLegacyFile('/core/modules/system/system.module'); + + $status = strtolower($input->getOption('status')); + $type = strtolower($input->getOption('type')); + $modules = strtolower($input->getArgument('module')); + + if ($modules) { + $config = $this->configurationManager->getConfiguration(); + $repo = $config->get('application.composer.repositories.default'); + + foreach ($modules as $module) { + $url = sprintf( + '%s/packages/drupal/%s.json', + $config->get('application.composer.packages.default'), + $module + ); + + try { + $data = $this->httpClient->getUrlAsJson($repo . $url); + } catch (\Exception $e) { + $io->error( + sprintf( + $this->trans('commands.module.debug.messages.no-results'), + $module + ) + ); + + return 1; + } + + $tableHeader = [ + ''.$data->package->name.'' + ]; + + $tableRows = []; + + $tableRows[] = [ + $data->package->description + ]; + + $tableRows[] = [ + ''.$this->trans('commands.module.debug.messages.total-downloads').'', + $data->package->downloads->total + ]; + + $tableRows[] = [ + ''.$this->trans('commands.module.debug.messages.total-monthly').'', + $data->package->downloads->monthly + ]; + + $tableRows[] = [ + ''.$this->trans('commands.module.debug.messages.total-daily').'', + $data->package->downloads->daily + ]; + + $io->table($tableHeader, $tableRows, 'compact'); + } + return 0; + } + + if ($status == 'installed') { + $status = 1; + } elseif ($status == 'uninstalled') { + $status = 0; + } else { + $status = -1; + } + + if ($type == 'core') { + $type = 'core'; + } elseif ($type == 'no-core') { + $type = ''; + } else { + $type = null; + } + + $tableHeader = [ + $this->trans('commands.module.debug.messages.id'), + $this->trans('commands.module.debug.messages.name'), + $this->trans('commands.module.debug.messages.package'), + $this->trans('commands.module.debug.messages.version'), + $this->trans('commands.module.debug.messages.schema-version'), + $this->trans('commands.module.debug.messages.status'), + $this->trans('commands.module.debug.messages.origin'), + ]; + + $tableRows = []; + $modules = system_rebuild_module_data(); + foreach ($modules as $module_id => $module) { + if ($status >= 0 && $status != $module->status) { + continue; + } + + if ($type !== null && $type !== $module->origin) { + continue; + } + + $module_status = ($module->status) ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled'); + $module_origin = ($module->origin) ? $module->origin : 'no core'; + $schema_version = (drupal_get_installed_schema_version($module_id)!= -1?drupal_get_installed_schema_version($module_id): ''); + + $tableRows [] = [ + $module_id, + $module->info['name'], + $module->info['package'], + $module->info['version'], + $schema_version, + $module_status, + $module_origin, + ]; + } + + $io->table($tableHeader, $tableRows, 'compact'); + } +}