1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file was previously qa_projects.inc. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Drupal\qa\Controller; |
8
|
|
|
|
9
|
|
|
use Drupal\Core\Controller\ControllerBase; |
|
|
|
|
10
|
|
|
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; |
|
|
|
|
11
|
|
|
use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface; |
|
|
|
|
12
|
|
|
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; |
|
|
|
|
13
|
|
|
use Drupal\Core\KeyValueStore\KeyValueStoreInterface; |
|
|
|
|
14
|
|
|
use Drupal\qa\System\Module; |
15
|
|
|
use Drupal\update\UpdateManagerInterface; |
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class ProjectsReportController. |
20
|
|
|
* |
21
|
|
|
* @package Drupal\qa\Controller |
22
|
|
|
*/ |
23
|
|
|
class ProjectsReportController extends ControllerBase { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface |
27
|
|
|
*/ |
28
|
|
|
protected $keyValueExpirable; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \Drupal\update\UpdateManagerInterface |
32
|
|
|
*/ |
33
|
|
|
protected $updateManager; |
34
|
|
|
|
35
|
|
|
public function __construct( |
36
|
|
|
UpdateManagerInterface $updateManager, |
37
|
|
|
KeyValueExpirableFactoryInterface $kveFactory |
38
|
|
|
) { |
39
|
|
|
$this->keyValueExpirable = $kveFactory->get('update'); |
40
|
|
|
$this->updateManager = $updateManager; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function create(ContainerInterface $container) { |
44
|
|
|
$updateManager = $container->get('update.manager'); |
45
|
|
|
$kve = $container->get('keyvalue.expirable'); |
46
|
|
|
return new static($updateManager, $kve); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Action. |
51
|
|
|
* |
52
|
|
|
* @return array<string,array|string> |
53
|
|
|
* A render array |
54
|
|
|
*/ |
55
|
|
|
public function action() { |
56
|
|
|
$projects = $this->buildProjects(); |
57
|
|
|
return $projects; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Build the list of projects. |
62
|
|
|
* |
63
|
|
|
* On most sites, this will just hold "drupal" and "OSInet QA", since most |
64
|
|
|
* code does not use the undocumented project info file key. |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
* A render array. |
68
|
|
|
*/ |
69
|
|
|
protected function buildProjects() { |
70
|
|
|
$this->keyValueExpirable->delete('update_project_projects'); |
71
|
|
|
$projects = $this->updateManager->getProjects(); |
72
|
|
|
$build = [ |
73
|
|
|
'#type' => 'table', |
74
|
|
|
'#header' => [ |
75
|
|
|
$this->t('Name'), |
76
|
|
|
$this->t('Type'), |
77
|
|
|
$this->t('Status'), |
78
|
|
|
], |
79
|
|
|
'#rows' => [], |
80
|
|
|
]; |
81
|
|
|
|
82
|
|
|
foreach ($projects as $projectName => $project) { |
83
|
|
|
$row = [ |
84
|
|
|
$projectName, |
85
|
|
|
$project['project_type'], |
86
|
|
|
$project['project_status'], |
87
|
|
|
]; |
88
|
|
|
$build['#rows'][] = $row; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $build; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param \Drupal\qa\Controller\Variable|NULL $variable |
96
|
|
|
* |
97
|
|
|
* @return string |
98
|
|
|
* |
99
|
|
|
* FIXME this is is legacy D7 one-off code. |
100
|
|
|
* |
101
|
|
|
* @deprecated |
102
|
|
|
*/ |
103
|
|
|
private final function qa_report_project(Variable $variable = NULL) { |
104
|
|
|
$c = cache_get('views_data:fr', 'cache_views'); |
|
|
|
|
105
|
|
|
$ret = '<pre>' . json_encode($c, JSON_PRETTY_PRINT) . '</pre>'; |
106
|
|
|
return $ret; |
107
|
|
|
$bc = drupal_get_breadcrumb(); |
|
|
|
|
108
|
|
|
$bc[] = l($this->t('Administration'), 'admin'); |
|
|
|
|
109
|
|
|
$bc[] = l($this->t('Reports'), 'admin/reports'); |
110
|
|
|
$bc[] = l($this->t('Quality Assurance'), 'admin/reports/qa'); |
111
|
|
|
$bc[] = l($this->t('Variables'), 'admin/reports/qa/variable'); |
112
|
|
|
drupal_set_breadcrumb($bc); |
|
|
|
|
113
|
|
|
|
114
|
|
|
drupal_set_title($this->t('Variable: %name', array('%name' => $variable->name)), PASS_THROUGH); |
|
|
|
|
115
|
|
|
return $variable->dump(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Page callback for projects list. |
120
|
|
|
* |
121
|
|
|
* @return string |
122
|
|
|
* |
123
|
|
|
* @FIXME This still uses the D7 info structure. |
124
|
|
|
* |
125
|
|
|
* @deprecated |
126
|
|
|
*/ |
127
|
|
|
private final function qa_report_projects() { |
128
|
|
|
$ret = '<h3>Projects</h3>'; |
129
|
|
|
drupal_static_reset('update_get_projects'); |
|
|
|
|
130
|
|
|
$GLOBALS['conf']['update_check_disabled'] = TRUE; |
131
|
|
|
$projects = update_get_projects(); |
|
|
|
|
132
|
|
|
ksort($projects); |
133
|
|
|
$ret .= kprint_r($projects, TRUE); |
|
|
|
|
134
|
|
|
|
135
|
|
|
$ret .= '<h3>Modules info</h3>'; |
136
|
|
|
list($modules, $projects) = Module::getInfo(); |
137
|
|
|
|
138
|
|
|
$header = array( |
139
|
|
|
$this->t('Project'), |
140
|
|
|
$this->t('Module'), |
141
|
|
|
$this->t('Module status'), |
142
|
|
|
$this->t('Project status'), |
143
|
|
|
); |
144
|
|
|
|
145
|
|
|
$rows = array(); |
146
|
|
|
$previous_project = ''; |
147
|
|
|
/** @var \Drupal\qa\System\Project $project */ |
148
|
|
|
foreach ($projects as $name => $project) { |
149
|
|
|
$row = array(); |
150
|
|
|
$project_cell = array( |
151
|
|
|
'data' => $name, |
152
|
|
|
); |
153
|
|
|
$count = $project->useCount(); |
154
|
|
|
if ($count > 1) { |
155
|
|
|
//$project_cell['rowspan'] = $count; |
156
|
|
|
} |
157
|
|
|
if ($name != $previous_project) { |
158
|
|
|
$previous_project = $name; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$enabled = $this->t('Enabled'); |
162
|
|
|
$disabled = $this->t('Disabled'); |
163
|
|
|
|
164
|
|
|
/** @var \Drupal\qa\System\Module $module */ |
165
|
|
|
foreach (array_values($project->modules) as $index => $module) { |
166
|
|
|
$row = array(); |
167
|
|
|
$row[] = ($index === 0) ? $project_cell : ''; |
168
|
|
|
|
169
|
|
|
$row[] = $module->name; |
170
|
|
|
$row[] = $module->isEnabled() ? $enabled : $disabled; |
171
|
|
|
|
172
|
|
|
if ($index === 0) { |
173
|
|
|
if ($count === 0) { |
174
|
|
|
$last_cell = array( |
175
|
|
|
'style' => 'background-color: #ff8080', |
176
|
|
|
'data' => $count, |
177
|
|
|
); |
178
|
|
|
} |
179
|
|
|
else { |
180
|
|
|
$last_cell = $count; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
else { |
184
|
|
|
$last_cell = ''; |
185
|
|
|
} |
186
|
|
|
$row[] = $last_cell; |
187
|
|
|
|
188
|
|
|
$rows[] = $row; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
return theme('table', array( |
|
|
|
|
192
|
|
|
'header' => $header, |
193
|
|
|
'rows' => $rows, |
194
|
|
|
)); |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
|
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