|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\qa\Plugin; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\Component\Discovery\DiscoveryException; |
|
|
|
|
|
|
6
|
|
|
use Drupal\Core\Plugin\DefaultPluginManager; |
|
|
|
|
|
|
7
|
|
|
use Drupal\Core\Cache\CacheBackendInterface; |
|
|
|
|
|
|
8
|
|
|
use Drupal\Core\Extension\ModuleHandlerInterface; |
|
|
|
|
|
|
9
|
|
|
use Drupal\qa\Annotation\QaCheck; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Provides the QA Check plugin manager. |
|
13
|
|
|
*/ |
|
14
|
|
|
class QaCheckManager extends DefaultPluginManager { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Constructs a new QaCheckManager object. |
|
18
|
|
|
* |
|
19
|
|
|
* @param \Traversable $namespaces |
|
20
|
|
|
* An object that implements \Traversable which contains the root paths |
|
21
|
|
|
* keyed by the corresponding namespace to look for plugin implementations. |
|
22
|
|
|
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend |
|
23
|
|
|
* Cache backend instance to use. |
|
24
|
|
|
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler |
|
25
|
|
|
* The module handler to invoke the alter hook with. |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { |
|
28
|
|
|
parent::__construct('Plugin/QaCheck', $namespaces, $module_handler, QaCheckInterface::class, QaCheck::class); |
|
29
|
|
|
|
|
30
|
|
|
$this->alterInfo('qa_check_info'); |
|
31
|
|
|
$this->setCacheBackend($cache_backend, 'qa_check_plugins'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* {@inheritdoc} |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $plugin_id |
|
38
|
|
|
* The plugin id. |
|
39
|
|
|
* @param array $configuration |
|
40
|
|
|
* The plugin configuration. |
|
41
|
|
|
* |
|
42
|
|
|
* @return \Drupal\qa\Plugin\QaCheckInterface |
|
43
|
|
|
* Plugins implement this interface instead of being plain objects. |
|
44
|
|
|
* |
|
45
|
|
|
* @throws \Drupal\Component\Plugin\Exception\PluginException |
|
46
|
|
|
*/ |
|
47
|
|
|
public function createInstance($plugin_id, array $configuration = []) { |
|
48
|
|
|
/** @var \Drupal\qa\Plugin\QaCheckInterface $res */ |
|
49
|
|
|
$res = parent::createInstance($plugin_id, $configuration); |
|
50
|
|
|
return $res; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Extract the package ID from a QaCheck plugin ID. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $pluginId |
|
57
|
|
|
* The QaCheck plugin ID. |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
* The package ID. |
|
61
|
|
|
* |
|
62
|
|
|
* @throws \Drupal\Component\Discovery\DiscoveryException |
|
63
|
|
|
*/ |
|
64
|
|
|
public static function getPackageId(string $pluginId): string { |
|
65
|
|
|
$id = strtok($pluginId, '.'); |
|
66
|
|
|
if ($id === FALSE) { |
|
67
|
|
|
throw new DiscoveryException("Ill-formed QaCheck plugin ID: ${pluginId}."); |
|
68
|
|
|
} |
|
69
|
|
|
return $id; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Return the check plugin definitions, indexed by their check package ID. |
|
74
|
|
|
* |
|
75
|
|
|
* @return array |
|
76
|
|
|
* The definitions. |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getPluginsByPackage(): array { |
|
79
|
|
|
$defs = $this->getDefinitions(); |
|
80
|
|
|
$packages = []; |
|
81
|
|
|
foreach ($defs as $id => $def) { |
|
82
|
|
|
$packageId = self::getPackageId($id); |
|
83
|
|
|
$packages[$packageId][] = $def; |
|
84
|
|
|
} |
|
85
|
|
|
return $packages; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
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