1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Admin\Action\Map\EditBorder; |
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\MapBorderTypeRepositoryInterface; |
11
|
|
|
use Stu\Orm\Repository\MapRepositoryInterface; |
12
|
|
|
|
13
|
|
|
final class EditBorder implements ActionControllerInterface |
14
|
|
|
{ |
15
|
|
|
public const ACTION_IDENTIFIER = 'B_EDIT_BORDER'; |
16
|
|
|
|
17
|
|
|
private EditBorderRequestInterface $editBorderRequest; |
18
|
|
|
|
19
|
|
|
private MapBorderTypeRepositoryInterface $mapBorderTypeRepository; |
20
|
|
|
|
21
|
|
|
private MapRepositoryInterface $mapRepository; |
22
|
|
|
|
23
|
|
|
public function __construct( |
24
|
|
|
EditBorderRequestInterface $editBorderRequest, |
25
|
|
|
MapBorderTypeRepositoryInterface $mapBorderTypeRepository, |
26
|
|
|
MapRepositoryInterface $mapRepository |
27
|
|
|
) { |
28
|
|
|
$this->editBorderRequest = $editBorderRequest; |
29
|
|
|
$this->mapBorderTypeRepository = $mapBorderTypeRepository; |
30
|
|
|
$this->mapRepository = $mapRepository; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function handle(GameControllerInterface $game): void |
34
|
|
|
{ |
35
|
|
|
$selectedField = $this->mapRepository->find($this->editBorderRequest->getFieldId()); |
36
|
|
|
|
37
|
|
|
if ($selectedField === null) { |
38
|
|
|
return; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$border = $this->mapBorderTypeRepository->find($this->editBorderRequest->getBorder()); |
42
|
|
|
if ($border === null) { |
43
|
|
|
return; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$selectedField->setBorderTypeId($border->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
|
|
|
|