Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
PluginCategoriesEntityDao | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
selectAllPluginCategories | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
insertPluginCategory | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
updatePluginCategory | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
deletePluginCategory | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Dao\Entities; |
6 | |
7 | use PeServer\App\Models\Data\Dto\PluginCategoryDto; |
8 | use PeServer\Core\Database\DaoBase; |
9 | use PeServer\Core\Database\DaoTrait; |
10 | use PeServer\Core\Database\DatabaseTableResult; |
11 | use PeServer\Core\Database\IDatabaseContext; |
12 | |
13 | class PluginCategoriesEntityDao extends DaoBase |
14 | { |
15 | use DaoTrait; |
16 | |
17 | #region function |
18 | |
19 | /** |
20 | * @return PluginCategoryDto[] |
21 | */ |
22 | public function selectAllPluginCategories(): array |
23 | { |
24 | $result = $this->context->selectOrdered( |
25 | <<<SQL |
26 | |
27 | select |
28 | plugin_categories.plugin_category_id, |
29 | plugin_categories.display_name, |
30 | plugin_categories.description |
31 | from |
32 | plugin_categories |
33 | order by |
34 | plugin_categories.plugin_category_id |
35 | |
36 | SQL, |
37 | [] |
38 | ); |
39 | |
40 | return $result->mapping(PluginCategoryDto::class); |
41 | } |
42 | |
43 | public function insertPluginCategory(string $pluginCategoryId, string $displayName, string $description): void |
44 | { |
45 | $this->context->insertSingle( |
46 | <<<SQL |
47 | |
48 | insert into |
49 | plugin_categories |
50 | ( |
51 | plugin_category_id, |
52 | display_name, |
53 | description |
54 | ) |
55 | values |
56 | ( |
57 | :plugin_category_id, |
58 | :display_name, |
59 | :description |
60 | ) |
61 | |
62 | SQL, |
63 | [ |
64 | 'plugin_category_id' => $pluginCategoryId, |
65 | 'display_name' => $displayName, |
66 | 'description' => $description, |
67 | ] |
68 | ); |
69 | } |
70 | |
71 | public function updatePluginCategory(string $pluginCategoryId, string $displayName, string $description): void |
72 | { |
73 | $this->context->updateByKey( |
74 | <<<SQL |
75 | |
76 | update |
77 | plugin_categories |
78 | set |
79 | display_name = :display_name, |
80 | description = :description |
81 | where |
82 | plugin_category_id = :plugin_category_id |
83 | |
84 | SQL, |
85 | [ |
86 | 'plugin_category_id' => $pluginCategoryId, |
87 | 'display_name' => $displayName, |
88 | 'description' => $description, |
89 | ] |
90 | ); |
91 | } |
92 | |
93 | public function deletePluginCategory(string $pluginCategoryId): void |
94 | { |
95 | $this->context->deleteByKey( |
96 | <<<SQL |
97 | |
98 | delete |
99 | from |
100 | plugin_categories |
101 | where |
102 | plugin_category_id = :plugin_category_id |
103 | |
104 | SQL, |
105 | [ |
106 | 'plugin_category_id' => $pluginCategoryId, |
107 | ] |
108 | ); |
109 | } |
110 | |
111 | #endregion |
112 | } |