Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PluginIndexLogic | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
validateImpl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
executeImpl | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\Plugin; |
6 | |
7 | use PeServer\App\Models\AppDatabaseCache; |
8 | use PeServer\App\Models\Cache\PluginCache; |
9 | use PeServer\App\Models\Cache\PluginCacheItem; |
10 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
11 | use PeServer\Core\Collection\Arr; |
12 | use PeServer\Core\Mvc\LogicCallMode; |
13 | use PeServer\Core\Mvc\LogicParameter; |
14 | use PeServer\Core\Mvc\Validator; |
15 | use PeServer\Core\Text; |
16 | |
17 | class PluginIndexLogic extends PageLogicBase |
18 | { |
19 | public function __construct(LogicParameter $parameter, private AppDatabaseCache $dbCache) |
20 | { |
21 | parent::__construct($parameter); |
22 | } |
23 | |
24 | protected function validateImpl(LogicCallMode $callMode): void |
25 | { |
26 | //NOP |
27 | } |
28 | |
29 | protected function executeImpl(LogicCallMode $callMode): void |
30 | { |
31 | $this->setValue('link_default_plugin', false); |
32 | |
33 | if (!$this->dbCache->existsPluginInformation()) { |
34 | $this->setValue('plugins', []); |
35 | $this->setValue('link_default_plugin', true); |
36 | $this->addCommonError("プラグインなし"); |
37 | $this->addCommonError("この状態は原則ありえない(標準プラグインすら未登録状態)"); |
38 | return; |
39 | } |
40 | |
41 | $pluginInformation = $this->dbCache->readPluginInformation(); |
42 | |
43 | $plugins = Arr::sortCallbackByValue( |
44 | $pluginInformation->items, |
45 | fn (PluginCacheItem $a, PluginCacheItem $b) => strcmp($a->pluginName, $b->pluginName) |
46 | ); |
47 | |
48 | $this->setValue('plugins', $plugins); |
49 | } |
50 | } |