|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Drupal\qa\Commands; |
|
6
|
|
|
|
|
7
|
|
|
use Drupal\qa\Controller\WorkflowsReportController; |
|
8
|
|
|
use Drupal\qa\Plugin\QaCheck\References\Integrity; |
|
9
|
|
|
use Drupal\qa\Plugin\QaCheck\System\UnusedExtensions; |
|
10
|
|
|
use Drupal\qa\Plugin\QaCheckManager; |
|
11
|
|
|
use Drupal\qa\Workflows\ContentModerationGraph; |
|
12
|
|
|
use Drupal\qa\Workflows\ContentModerationGrid; |
|
13
|
|
|
use Drush\Commands\DrushCommands; |
|
|
|
|
|
|
14
|
|
|
use OSInet\qa\ForceRemoved; |
|
15
|
|
|
use Symfony\Component\Yaml\Yaml; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* A Drush commandfile. |
|
19
|
|
|
* |
|
20
|
|
|
* In addition to this file, you need a drush.services.yml |
|
21
|
|
|
* in root of your module, and a composer.json file that provides the name |
|
22
|
|
|
* of the services file to use. |
|
23
|
|
|
* |
|
24
|
|
|
* See these files for an example of injecting Drupal services: |
|
25
|
|
|
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php |
|
26
|
|
|
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml |
|
27
|
|
|
*/ |
|
28
|
|
|
class QaCommands extends DrushCommands { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The plugin.manager.qa_check service. |
|
32
|
|
|
* |
|
33
|
|
|
* @var \Drupal\qa\Plugin\QaCheckManager |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $qam; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* QaCommands constructor. |
|
39
|
|
|
* |
|
40
|
|
|
* @param \Drupal\qa\Plugin\QaCheckManager $qam |
|
41
|
|
|
* The plugin.manager.qa_check service. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct(QaCheckManager $qam) { |
|
44
|
|
|
$this->qam = $qam; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Show the content moderation as a table. |
|
49
|
|
|
* |
|
50
|
|
|
* @command como:table |
|
51
|
|
|
* @aliases cmt,como-table |
|
52
|
|
|
*/ |
|
53
|
|
|
public function table() { |
|
54
|
|
|
$table = ContentModerationGrid::create(\Drupal::getContainer()); |
|
55
|
|
|
$table->report(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Show the content moderation as a Graphviz DOT file. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $workflow |
|
62
|
|
|
* The machine name of a workflow. |
|
63
|
|
|
* |
|
64
|
|
|
* @command como:graphviz |
|
65
|
|
|
* @aliases cmg,como-graphviz |
|
66
|
|
|
*/ |
|
67
|
|
|
public function graphviz(string $workflow = '') { |
|
68
|
|
|
$graph = ContentModerationGraph::create(\Drupal::getContainer()); |
|
69
|
|
|
echo $graph->report(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Show a summary of available workflows. |
|
74
|
|
|
* |
|
75
|
|
|
* @command qa:workflows-list |
|
76
|
|
|
* @aliases qawl,qa-workflows-list |
|
77
|
|
|
*/ |
|
78
|
|
|
public function workflowsList() { |
|
79
|
|
|
$listBuilder = WorkflowsReportController::create(\Drupal::getContainer()); |
|
80
|
|
|
$list = $listBuilder->getWorkflowSummary( |
|
81
|
|
|
$listBuilder->storage->loadMultiple() |
|
82
|
|
|
); |
|
83
|
|
|
$this->output->writeln(Yaml::dump($list)); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Build a Graphviz DOT file showing the module and theme dependencies. |
|
88
|
|
|
* |
|
89
|
|
|
* @command qa:dependencies |
|
90
|
|
|
* @aliases qadep,qa-dependencies |
|
91
|
|
|
*/ |
|
92
|
|
|
public function dependencies() { |
|
93
|
|
|
/** @var \Drupal\qa\Dependencies $qaDep */ |
|
94
|
|
|
$qaDep = \Drupal::service('qa.dependencies'); |
|
95
|
|
|
$g = $qaDep->build(); |
|
96
|
|
|
echo $g->build(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Show broken entity_reference fields. |
|
101
|
|
|
* |
|
102
|
|
|
* @command qa:references:integrity |
|
103
|
|
|
* |
|
104
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
|
105
|
|
|
*/ |
|
106
|
|
|
public function referencesIntegrity() { |
|
107
|
|
|
$check = $this->qam->createInstance(Integrity::NAME); |
|
108
|
|
|
$pass = $check->run(); |
|
109
|
|
|
$res = [ |
|
110
|
|
|
'age' => $pass->life->age(), |
|
111
|
|
|
'ok' => $pass->ok, |
|
112
|
|
|
'result' => [], |
|
113
|
|
|
]; |
|
114
|
|
|
/** @var \Drupal\qa\Result $result */ |
|
115
|
|
|
foreach ($pass->result as $key => $result) { |
|
116
|
|
|
$res['result'][$key] = [ |
|
117
|
|
|
'ok' => $result->ok, |
|
118
|
|
|
'data' => $result->data, |
|
119
|
|
|
]; |
|
120
|
|
|
} |
|
121
|
|
|
$this->output->writeln(Yaml::dump($res, 4, 2)); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Show projects entirely unused and unused themes. |
|
126
|
|
|
* |
|
127
|
|
|
* @command qa:system:unused |
|
128
|
|
|
* |
|
129
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
|
130
|
|
|
*/ |
|
131
|
|
|
public function systemUnused() { |
|
132
|
|
|
$check = $this->qam->createInstance(UnusedExtensions::NAME); |
|
133
|
|
|
$pass = $check->run(); |
|
134
|
|
|
$res = [ |
|
135
|
|
|
'age' => $pass->life->age(), |
|
136
|
|
|
'ok' => $pass->ok, |
|
137
|
|
|
'result' => [], |
|
138
|
|
|
]; |
|
139
|
|
|
/** @var \Drupal\qa\Result $result */ |
|
140
|
|
|
foreach ($pass->result as $key => $result) { |
|
141
|
|
|
$res['result'][$key] = [ |
|
142
|
|
|
'ok' => $result->ok, |
|
143
|
|
|
'data' => $result->data, |
|
144
|
|
|
]; |
|
145
|
|
|
} |
|
146
|
|
|
$this->output->writeln(Yaml::dump($res, 4, 2)); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* List extensions removed without a clean uninstall. |
|
151
|
|
|
* |
|
152
|
|
|
* @command qa:force-removed |
|
153
|
|
|
* @aliases qafrm,qa-force-removed |
|
154
|
|
|
*/ |
|
155
|
|
|
public function forceRemoved() { |
|
156
|
|
|
$finder = ForceRemoved::create(); |
|
157
|
|
|
echo $finder->find(); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
} |
|
161
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths