Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PluginDetailLogic | |
0.00% |
0 / 16 |
|
0.00% |
0 / 3 |
12 | |
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 / 14 |
|
0.00% |
0 / 1 |
2 |
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\PluginCacheCategory; |
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\Collection\Collections; |
13 | use PeServer\Core\Mvc\LogicCallMode; |
14 | use PeServer\Core\Mvc\LogicParameter; |
15 | use PeServer\Core\Uuid; |
16 | |
17 | class PluginDetailLogic 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 | $pluginInformation = $this->dbCache->readPluginInformation(); |
32 | /** @var PluginCacheItem */ |
33 | $plugin = Collections::from($pluginInformation->items) |
34 | ->first(function ($i) { |
35 | return Uuid::isEqualGuid($i->pluginId, $this->getRequest('plugin_id')); |
36 | }); |
37 | |
38 | $categories = Collections::from($pluginInformation->categories) |
39 | ->where(fn(PluginCacheCategory $i) => Arr::in($plugin->categoryIds, $i->categoryId)) |
40 | ->toArray() |
41 | ; |
42 | $categories = Arr::sortCallbackByValue($categories, function (PluginCacheCategory $a, PluginCacheCategory $b) { |
43 | return $a->categoryName <=> $b->categoryName; |
44 | }); |
45 | |
46 | $this->setValue('plugin', $plugin); |
47 | $this->setValue('categories', $categories); |
48 | } |
49 | } |