Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AdministratorApiBackupLogic | |
0.00% |
0 / 11 |
|
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 / 9 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Api\AdministratorApi; |
6 | |
7 | use PeServer\App\Models\AuditLog; |
8 | use PeServer\App\Models\Domain\Api\ApiLogicBase; |
9 | use PeServer\App\Models\Domain\AppArchiver; |
10 | use PeServer\App\Models\ResponseJson; |
11 | use PeServer\Core\Mvc\LogicCallMode; |
12 | use PeServer\Core\Mvc\LogicParameter; |
13 | use PeServer\Core\Utc; |
14 | |
15 | class AdministratorApiBackupLogic extends ApiLogicBase |
16 | { |
17 | public function __construct(LogicParameter $parameter, private AppArchiver $appArchiver) |
18 | { |
19 | parent::__construct($parameter); |
20 | } |
21 | |
22 | #region ApiLogicBase |
23 | |
24 | protected function validateImpl(LogicCallMode $callMode): void |
25 | { |
26 | //NOP |
27 | } |
28 | |
29 | protected function executeImpl(LogicCallMode $callMode): void |
30 | { |
31 | $size = $this->appArchiver->backup(); |
32 | $this->appArchiver->rotate(); |
33 | |
34 | $this->writeAuditLogCurrentUser(AuditLog::API_ADMINISTRATOR_BACKUP, ['size' => $size]); |
35 | |
36 | // 日曜だけバックアップ送信でいいわ |
37 | $week = (int)$this->beginTimestamp->format('w'); |
38 | if ($week === 0) { |
39 | $this->appArchiver->sendLatestArchive(AdministratorApiBackupLogic::class, true); |
40 | } |
41 | |
42 | $this->setResponseJson(ResponseJson::success([ |
43 | 'size' => $size, |
44 | ])); |
45 | } |
46 | |
47 | #endregion |
48 | } |