1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Component\Player\Deletion\Handler; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
8
|
|
|
use Override; |
|
|
|
|
9
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemManagerInterface; |
10
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
11
|
|
|
use Stu\Module\Spacecraft\Lib\Interaction\ShipUndockingInterface; |
12
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftRemoverInterface; |
13
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface; |
14
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
15
|
|
|
use Stu\Orm\Entity\StationInterface; |
16
|
|
|
use Stu\Orm\Entity\UserInterface; |
17
|
|
|
use Stu\Orm\Repository\ConstructionProgressRepositoryInterface; |
18
|
|
|
use Stu\Orm\Repository\SpacecraftRepositoryInterface; |
19
|
|
|
|
20
|
|
|
final class SpacecraftDeletionHandler implements PlayerDeletionHandlerInterface |
21
|
|
|
{ |
22
|
2 |
|
public function __construct( |
23
|
|
|
private SpacecraftRepositoryInterface $spacecraftRepository, |
24
|
|
|
private ConstructionProgressRepositoryInterface $constructionProgressRepository, |
25
|
|
|
private SpacecraftRemoverInterface $spacecraftRemover, |
26
|
|
|
private SpacecraftSystemManagerInterface $spacecraftSystemManager, |
27
|
|
|
private SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory, |
28
|
|
|
private ShipUndockingInterface $shipUndocking, |
29
|
|
|
private EntityManagerInterface $entityManager |
30
|
2 |
|
) {} |
31
|
|
|
|
32
|
1 |
|
#[Override] |
33
|
|
|
public function delete(UserInterface $user): void |
34
|
|
|
{ |
35
|
1 |
|
foreach ($this->spacecraftRepository->getByUser($user) as $spacecraft) { |
36
|
|
|
|
37
|
|
|
// do nothing if tradepost, because it gets handled in TradepostDeletionHandler |
38
|
|
|
if ( |
39
|
1 |
|
$spacecraft instanceof StationInterface |
40
|
1 |
|
&& $spacecraft->getTradePost() !== null |
41
|
|
|
) { |
42
|
1 |
|
continue; |
43
|
|
|
} |
44
|
|
|
|
45
|
1 |
|
if ($spacecraft instanceof StationInterface) { |
46
|
1 |
|
$this->deleteConstructionProgress($spacecraft); |
47
|
1 |
|
$this->undockAllDockedShips($spacecraft); |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
$this->unsetTractor($spacecraft); |
51
|
1 |
|
$this->spacecraftRemover->remove($spacecraft, true); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
1 |
|
private function deleteConstructionProgress(StationInterface $station): void |
56
|
|
|
{ |
57
|
1 |
|
$progress = $station->getConstructionProgress(); |
58
|
1 |
|
if ($progress !== null) { |
59
|
1 |
|
$this->constructionProgressRepository->delete($progress); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
private function undockAllDockedShips(StationInterface $station): void |
64
|
|
|
{ |
65
|
1 |
|
$anyDocked = $this->shipUndocking->undockAllDocked($station); |
66
|
|
|
|
67
|
1 |
|
if ($anyDocked) { |
68
|
1 |
|
$this->entityManager->flush(); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
private function unsetTractor(SpacecraftInterface $spacecraft): void |
73
|
|
|
{ |
74
|
1 |
|
$tractoredShip = $spacecraft->getTractoredShip(); |
75
|
|
|
|
76
|
1 |
|
if ($tractoredShip === null) { |
77
|
1 |
|
return; |
78
|
|
|
} |
79
|
|
|
|
80
|
1 |
|
$this->spacecraftSystemManager->deactivate( |
81
|
1 |
|
$this->spacecraftWrapperFactory->wrapSpacecraft($spacecraft), |
82
|
1 |
|
SpacecraftSystemTypeEnum::TRACTOR_BEAM, |
83
|
1 |
|
true |
84
|
1 |
|
); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths