Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AjaxPluginCategoryDeleteLogic | |
0.00% |
0 / 18 |
|
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 / 16 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\Ajax; |
6 | |
7 | use PeServer\App\Models\AppDatabaseCache; |
8 | use PeServer\App\Models\Dao\Entities\PluginCategoriesEntityDao; |
9 | use PeServer\App\Models\Dao\Entities\PluginCategoryMappingsEntityDao; |
10 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
11 | use PeServer\App\Models\ResponseJson; |
12 | use PeServer\App\Models\SessionKey; |
13 | use PeServer\Core\Database\IDatabaseContext; |
14 | use PeServer\Core\Http\HttpStatus; |
15 | use PeServer\Core\Mvc\LogicCallMode; |
16 | use PeServer\Core\Mvc\LogicParameter; |
17 | use PeServer\Core\Text; |
18 | use PeServer\Core\Throws\HttpStatusException; |
19 | use PeServer\Core\TypeUtility; |
20 | |
21 | class AjaxPluginCategoryDeleteLogic extends PageLogicBase |
22 | { |
23 | public function __construct(LogicParameter $parameter, private AppDatabaseCache $dbCache) |
24 | { |
25 | parent::__construct($parameter); |
26 | } |
27 | |
28 | #region PageLogicBase |
29 | |
30 | protected function validateImpl(LogicCallMode $callMode): void |
31 | { |
32 | //NOP |
33 | } |
34 | |
35 | protected function executeImpl(LogicCallMode $callMode): void |
36 | { |
37 | $params = [ |
38 | 'plugin_category_id' => $this->getRequest('plugin_category_id'), |
39 | ]; |
40 | |
41 | if (Text::isNullOrWhiteSpace($params['plugin_category_id'])) { |
42 | throw new HttpStatusException(HttpStatus::BadRequest); |
43 | } |
44 | |
45 | $database = $this->openDatabase(); |
46 | $database->transaction(function (IDatabaseContext $context) use ($params) { |
47 | $pluginCategoryMappingsEntityDao = new PluginCategoryMappingsEntityDao($context); |
48 | $pluginCategoriesEntityDao = new PluginCategoriesEntityDao($context); |
49 | |
50 | $pluginCategoryId = $params['plugin_category_id']; |
51 | |
52 | $pluginCategoryMappingsEntityDao->deletePluginCategoryMappings($pluginCategoryId); |
53 | $pluginCategoriesEntityDao->deletePluginCategory($pluginCategoryId); |
54 | |
55 | return true; |
56 | }); |
57 | |
58 | $this->setResponseJson(ResponseJson::success($params)); |
59 | |
60 | $this->dbCache->exportPluginInformation(); |
61 | } |
62 | |
63 | #endregion |
64 | } |