|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Admin\Action\Map\EditAdminRegion; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Module\Admin\View\Map\Noop\Noop; |
|
8
|
|
|
use Stu\Module\Control\ActionControllerInterface; |
|
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
10
|
|
|
use Stu\Orm\Repository\MapRegionRepositoryInterface; |
|
11
|
|
|
use Stu\Orm\Repository\MapRepositoryInterface; |
|
12
|
|
|
|
|
13
|
|
|
final class EditAdminRegion implements ActionControllerInterface |
|
14
|
|
|
{ |
|
15
|
|
|
public const ACTION_IDENTIFIER = 'B_EDIT_ADMIN_REGION'; |
|
16
|
|
|
|
|
17
|
|
|
private EditAdminRegionRequestInterface $editAdminRegionRequest; |
|
18
|
|
|
|
|
19
|
|
|
private MapRegionRepositoryInterface $mapRegionRepository; |
|
20
|
|
|
|
|
21
|
|
|
private MapRepositoryInterface $mapRepository; |
|
22
|
|
|
|
|
23
|
|
|
public function __construct( |
|
24
|
|
|
EditAdminRegionRequestInterface $editAdminRegionRequest, |
|
25
|
|
|
MapRegionRepositoryInterface $mapRegionRepository, |
|
26
|
|
|
MapRepositoryInterface $mapRepository |
|
27
|
|
|
) { |
|
28
|
|
|
$this->editAdminRegionRequest = $editAdminRegionRequest; |
|
29
|
|
|
$this->mapRegionRepository = $mapRegionRepository; |
|
30
|
|
|
$this->mapRepository = $mapRepository; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function handle(GameControllerInterface $game): void |
|
34
|
|
|
{ |
|
35
|
|
|
$selectedField = $this->mapRepository->find($this->editAdminRegionRequest->getFieldId()); |
|
36
|
|
|
|
|
37
|
|
|
if ($selectedField === null) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$region = $this->mapRegionRepository->find($this->editAdminRegionRequest->getAdminRegionId()); |
|
42
|
|
|
if ($region === null) { |
|
43
|
|
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$selectedField->setAdminRegionId($region->getId()); |
|
47
|
|
|
|
|
48
|
|
|
$this->mapRepository->save($selectedField); |
|
49
|
|
|
|
|
50
|
|
|
$game->setView(Noop::VIEW_IDENTIFIER); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function performSessionCheck(): bool |
|
54
|
|
|
{ |
|
55
|
|
|
return false; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|