1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Destruction\Handler; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use RuntimeException; |
7
|
|
|
use Stu\Lib\Information\InformationInterface; |
8
|
|
|
use Stu\Module\Ship\Lib\TholianWebUtilInterface; |
9
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestroyerInterface; |
10
|
|
|
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestructionCauseEnum; |
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface; |
12
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
13
|
|
|
use Stu\Orm\Entity\ShipInterface; |
14
|
|
|
use Stu\Orm\Entity\TholianWebInterface; |
15
|
|
|
use Stu\Orm\Repository\SpacecraftRepositoryInterface; |
16
|
|
|
use Stu\Orm\Repository\SpacecraftSystemRepositoryInterface; |
17
|
|
|
use Stu\Orm\Repository\TholianWebRepositoryInterface; |
18
|
|
|
|
19
|
|
|
class TholianWebDestruction implements SpacecraftDestructionHandlerInterface |
20
|
|
|
{ |
21
|
1 |
|
public function __construct( |
22
|
|
|
private TholianWebRepositoryInterface $tholianWebRepository, |
23
|
|
|
private SpacecraftSystemRepositoryInterface $spacecraftSystemRepository, |
24
|
|
|
private SpacecraftRepositoryInterface $spacecraftRepository, |
25
|
|
|
private SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory, |
26
|
|
|
private TholianWebUtilInterface $tholianWebUtil |
27
|
1 |
|
) {} |
28
|
|
|
|
29
|
|
|
#[Override] |
30
|
|
|
public function handleSpacecraftDestruction( |
31
|
|
|
?SpacecraftDestroyerInterface $destroyer, |
32
|
|
|
SpacecraftWrapperInterface $destroyedSpacecraftWrapper, |
33
|
|
|
SpacecraftDestructionCauseEnum $cause, |
34
|
|
|
InformationInterface $informations, |
35
|
|
|
): void { |
36
|
|
|
|
37
|
|
|
$tholianWeb = $destroyedSpacecraftWrapper->get(); |
38
|
|
|
if (!$tholianWeb instanceof TholianWebInterface) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
foreach ($tholianWeb->getCapturedSpacecrafts() as $spacecraft) { |
43
|
|
|
$spacecraft->setHoldingWeb(null); |
44
|
|
|
$this->spacecraftRepository->save($spacecraft); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$owningSpacecraftSystem = $this->spacecraftSystemRepository->getWebOwningShipSystem($tholianWeb->getId()); |
48
|
|
|
if ($owningSpacecraftSystem === null) { |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$this->tholianWebUtil->resetWebHelpers($tholianWeb, $this->spacecraftWrapperFactory); |
53
|
|
|
|
54
|
|
|
/** @var ShipInterface */ |
55
|
|
|
$owningShip = $owningSpacecraftSystem->getSpacecraft(); |
56
|
|
|
|
57
|
|
|
$webEmitterSystemData = $this->spacecraftWrapperFactory |
58
|
|
|
->wrapShip($owningShip) |
59
|
|
|
->getWebEmitterSystemData(); |
60
|
|
|
|
61
|
|
|
if ($webEmitterSystemData === null) { |
62
|
|
|
throw new RuntimeException('this should not happen'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$webEmitterSystemData->setOwnedWebId(null) |
66
|
|
|
->update(); |
67
|
|
|
|
68
|
|
|
$this->tholianWebRepository->delete($tholianWeb); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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