|
10 | 10 | namespace Piwik\Plugins\OpenApiDocs; |
11 | 11 |
|
12 | 12 | use Piwik\Piwik; |
| 13 | +use Piwik\Plugins\OpenApiDocs\Generation\PluginListProvider; |
13 | 14 | use Piwik\Plugin\Manager; |
14 | 15 | use Piwik\Plugins\OpenApiDocs\Specs\SpecGenerator; |
15 | 16 | use Piwik\Plugins\OpenApiDocs\Specs\PathResolver; |
16 | 17 |
|
17 | 18 | /** |
18 | 19 | * Provides Reporting API endpoints for reading OpenAPI plugin configuration and specifications. |
19 | 20 | * |
20 | | - * Exposes endpoints to return the configured plugin whitelist, read pre-generated spec files, |
| 21 | + * Exposes endpoints to return the effective plugin list for spec generation, read pre-generated spec files, |
21 | 22 | * or generate plugin OpenAPI specifications on demand. |
22 | 23 | * |
23 | 24 | * @method static \Piwik\Plugins\OpenApiDocs\API getInstance() |
24 | 25 | */ |
25 | 26 | class API extends \Piwik\Plugin\API |
26 | 27 | { |
27 | 28 | /** |
28 | | - * Returns the plugin names configured for OpenApiDocs spec generation. |
| 29 | + * Returns the plugin names used for OpenApiDocs spec generation. |
29 | 30 | * |
30 | | - * @return array<int, string> The configured whitelist of plugin names from |
31 | | - * `config/plugins.php`. |
| 31 | + * @return array<int, string> |
32 | 32 | */ |
33 | 33 | public function getPluginWhitelist(): array |
34 | 34 | { |
35 | 35 | Piwik::checkUserHasSomeViewAccess(); |
36 | 36 |
|
37 | | - $pluginWhitelist = $this->loadPluginWhitelist(); |
38 | | - if (!is_array($pluginWhitelist)) { |
39 | | - throw new \Exception('OpenApiDocs plugin whitelist config is invalid.'); |
40 | | - } |
41 | | - |
42 | | - return $pluginWhitelist; |
| 37 | + return PluginListProvider::getPluginsForSpecGeneration(); |
43 | 38 | } |
44 | 39 |
|
45 | 40 | /** |
@@ -88,14 +83,6 @@ protected function getSpecFilePath(string $pluginName): string |
88 | 83 | return $this->getSpecPathResolver()->getSpecFilePath($pluginName); |
89 | 84 | } |
90 | 85 |
|
91 | | - /** |
92 | | - * @return mixed |
93 | | - */ |
94 | | - protected function loadPluginWhitelist() |
95 | | - { |
96 | | - return require __DIR__ . '/config/plugins.php'; |
97 | | - } |
98 | | - |
99 | 86 | protected function isSpecFileReadable(string $filePath): bool |
100 | 87 | { |
101 | 88 | return is_file($filePath) && is_readable($filePath); |
@@ -126,7 +113,6 @@ protected function getSpecPathResolver(): PathResolver |
126 | 113 | { |
127 | 114 | return new PathResolver(); |
128 | 115 | } |
129 | | - |
130 | 116 | /** |
131 | 117 | * Generates an OpenAPI specification for one or more plugins and returns it immediately. |
132 | 118 | * |
|
0 commit comments