1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\qa\Controller; |
4
|
|
|
|
5
|
|
|
use Drupal\Core\Controller\ControllerBase; |
6
|
|
|
use Drupal\qa\Data; |
7
|
|
|
use Drupal\qa\Plugin\QaCheckManager; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class ControlsListController. |
12
|
|
|
* |
13
|
|
|
* @package Drupal\qa\Controller |
14
|
|
|
*/ |
15
|
|
|
class CheckListController extends ControllerBase { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The plugin.manager.qa_check service. |
19
|
|
|
* |
20
|
|
|
* @var \Drupal\qa\Plugin\QaCheckManager |
21
|
|
|
*/ |
22
|
|
|
protected $qam; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* CheckListController constructor. |
26
|
|
|
* |
27
|
|
|
* @param \Drupal\qa\Plugin\QaCheckManager $qam |
28
|
|
|
* The plugin.manager.qa_check service. |
29
|
|
|
*/ |
30
|
|
|
public function __construct(QaCheckManager $qam) { |
31
|
|
|
$this->qam = $qam; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public static function create(ContainerInterface $container) { |
38
|
|
|
$qam = $container->get(Data::MANAGER); |
39
|
|
|
assert($qam instanceof QaCheckManager); |
40
|
|
|
return new static($qam); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Controller listing the available plugins. |
45
|
|
|
* |
46
|
|
|
* @return array |
47
|
|
|
* A render array. |
48
|
|
|
*/ |
49
|
|
|
public function report() { |
50
|
|
|
$checks = [ |
51
|
|
|
'#theme' => 'item_list', |
52
|
|
|
'#items' => [], |
53
|
|
|
]; |
54
|
|
|
$pp = $this->qam->getPluginsByPackage(); |
55
|
|
|
foreach ($pp as $package => $plugins) { |
56
|
|
|
$group = [ |
57
|
|
|
'#theme' => 'item_list', |
58
|
|
|
'#items' => [], |
59
|
|
|
'#title' => ucfirst($package), |
60
|
|
|
]; |
61
|
|
|
foreach ($plugins as $def) { |
62
|
|
|
$label = $def['label']; |
63
|
|
|
$props = []; |
64
|
|
|
if ($def['usesBatch'] ?? FALSE) { |
65
|
|
|
$props[] = $this->t('batch'); |
66
|
|
|
} |
67
|
|
|
if (($def['steps'] ?? 1) > 1) { |
68
|
|
|
$props[] = $this->formatPlural($def['steps'], "1 step", |
69
|
|
|
"@count steps", ['@count' => $def['steps']], |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
if (!empty($props)) { |
73
|
|
|
$label .= ' (' . implode(', ', $props) . ')'; |
74
|
|
|
} |
75
|
|
|
$details = $def['details']; |
76
|
|
|
$group['#items'][] = [ |
77
|
|
|
'#markup' => "${label}<br /><small>${details}</small>", |
78
|
|
|
]; |
79
|
|
|
} |
80
|
|
|
$checks['#items'][] = $group; |
81
|
|
|
} |
82
|
|
|
return $checks; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|