forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleDebugCommand.php
More file actions
87 lines (72 loc) · 2.69 KB
/
Copy pathModuleDebugCommand.php
File metadata and controls
87 lines (72 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @file
* Contains \Drupal\AppConsole\Command\ModuleDebugCommand.
*/
namespace Drupal\AppConsole\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ModuleDebugCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('module:debug')
->setDescription($this->trans('commands.module.debug.description'))
->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)
{
$status = $input->getOption('status');
$type = $input->getOption('type');
if (strtolower($status) == 'enabled') {
$status = 1;
} elseif (strtolower($status) == 'disabled') {
$status = 0;
} else {
$status = -1;
}
if (strtolower($type) == 'core') {
$type = 'core';
} elseif (strtolower($type) == 'no-core') {
$type = '';
} else {
$type = null;
}
$table = $this->getHelperSet()->get('table');
$table->setlayout($table::LAYOUT_COMPACT);
$this->getAllModules($status, $type, $output, $table);
}
protected function getAllModules($status, $type, $output, $table)
{
$table->setHeaders(
[
$this->trans('commands.module.debug.messages.id'),
$this->trans('commands.module.debug.messages.name'),
$this->trans('commands.module.debug.messages.status'),
$this->trans('commands.module.debug.messages.package'),
$this->trans('commands.module.debug.messages.origin'),
]);
$table->setlayout($table::LAYOUT_COMPACT);
$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.enabled') : $this->trans('commands.module.debug.messages.disabled');
$table->addRow([
$module_id,
$module->info['name'],
$module_status,
$module->info['package'],
$module->origin
]);
}
$table->render($output);
}
}