Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ManagementVersionLogic | |
0.00% |
0 / 27 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
startup | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
validateImpl | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
executeImpl | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\Management; |
6 | |
7 | use PeServer\App\Models\AppConfiguration; |
8 | use PeServer\App\Models\AppCryptography; |
9 | use PeServer\App\Models\AppDatabaseCache; |
10 | use PeServer\App\Models\AuditLog; |
11 | use PeServer\App\Models\Dao\Entities\PeSettingEntityDao; |
12 | use PeServer\App\Models\Dao\Entities\UserAuthenticationsEntityDao; |
13 | use PeServer\App\Models\Dao\Entities\UsersEntityDao; |
14 | use PeServer\App\Models\Domain\AccountValidator; |
15 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
16 | use PeServer\App\Models\Domain\PeVersionUpdater; |
17 | use PeServer\App\Models\Domain\UserLevel; |
18 | use PeServer\App\Models\Domain\UserState; |
19 | use PeServer\App\Models\Domain\UserUtility; |
20 | use PeServer\App\Models\SessionKey; |
21 | use PeServer\Core\Collection\Arr; |
22 | use PeServer\Core\Cryptography; |
23 | use PeServer\Core\Database\IDatabaseContext; |
24 | use PeServer\Core\Mvc\LogicCallMode; |
25 | use PeServer\Core\Mvc\LogicParameter; |
26 | use PeServer\Core\Mvc\Validator; |
27 | use PeServer\Core\Text; |
28 | |
29 | class ManagementVersionLogic extends PageLogicBase |
30 | { |
31 | public function __construct(LogicParameter $parameter, private AppConfiguration $config, private AppDatabaseCache $dbCache) |
32 | { |
33 | parent::__construct($parameter); |
34 | } |
35 | |
36 | protected function startup(LogicCallMode $callMode): void |
37 | { |
38 | $this->registerParameterKeys([ |
39 | 'version', |
40 | 'release_url', |
41 | ], true); |
42 | |
43 | $this->setValue('release_url', $this->config->setting->api->releaseUrl); |
44 | } |
45 | |
46 | protected function validateImpl(LogicCallMode $callMode): void |
47 | { |
48 | if ($callMode === LogicCallMode::Initialize) { |
49 | return; |
50 | } |
51 | |
52 | $this->validation('version', function ($key, $value) { |
53 | $this->validator->isNotWhiteSpace($key, $value); |
54 | }); |
55 | } |
56 | |
57 | protected function executeImpl(LogicCallMode $callMode): void |
58 | { |
59 | $database = $this->openDatabase(); |
60 | |
61 | if ($callMode === LogicCallMode::Initialize) { |
62 | $peSettingEntityDao = new PeSettingEntityDao($database); |
63 | $version = $peSettingEntityDao->selectPeSettingVersion(); |
64 | |
65 | $this->setValue('version', $version); |
66 | return; |
67 | } |
68 | |
69 | $result = $database->transaction(function (IDatabaseContext $context) { |
70 | $peVersionUpdater = new PeVersionUpdater(); |
71 | |
72 | $peVersionUpdater->updateDatabase($context, $this->config->setting->config->address->families->pluginUpdateInfoUrlBase, $this->getRequest('version')); |
73 | |
74 | return true; |
75 | }); |
76 | |
77 | if (!$result) { |
78 | $this->addCommonError('あかん'); |
79 | return; |
80 | } |
81 | |
82 | $this->dbCache->exportPluginInformation(); |
83 | |
84 | $this->addTemporaryMessage('バージョン更新'); |
85 | } |
86 | } |