|
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\ShipWrapperInterface; |
|
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\Repository\SpacecraftRepositoryInterface; |
|
15
|
|
|
use Stu\Orm\Repository\SpacecraftSystemRepositoryInterface; |
|
16
|
|
|
use Stu\Orm\Repository\TholianWebRepositoryInterface; |
|
17
|
|
|
|
|
18
|
|
|
class TholianWebDestruction implements SpacecraftDestructionHandlerInterface |
|
19
|
|
|
{ |
|
20
|
|
|
public function __construct( |
|
21
|
|
|
private TholianWebRepositoryInterface $tholianWebRepository, |
|
22
|
|
|
private SpacecraftSystemRepositoryInterface $spacecraftSystemRepository, |
|
23
|
|
|
private SpacecraftRepositoryInterface $spacecraftRepository, |
|
24
|
|
|
private SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory |
|
25
|
|
|
) {} |
|
26
|
|
|
|
|
27
|
|
|
#[Override] |
|
28
|
|
|
public function handleSpacecraftDestruction( |
|
29
|
|
|
?SpacecraftDestroyerInterface $destroyer, |
|
30
|
|
|
SpacecraftWrapperInterface $destroyedSpacecraftWrapper, |
|
31
|
|
|
SpacecraftDestructionCauseEnum $cause, |
|
32
|
|
|
InformationInterface $informations, |
|
33
|
|
|
): void { |
|
34
|
|
|
|
|
35
|
|
|
if (!$destroyedSpacecraftWrapper instanceof ShipWrapperInterface) { |
|
36
|
|
|
return; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$tholianWeb = $destroyedSpacecraftWrapper->get()->getTholianWeb(); |
|
40
|
|
|
if ($tholianWeb === null) { |
|
41
|
|
|
return; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
foreach ($tholianWeb->getCapturedShips() as $ship) { |
|
45
|
|
|
$ship->setHoldingWeb(null); |
|
46
|
|
|
$this->spacecraftRepository->save($ship); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$owningSpacecraftSystem = $this->spacecraftSystemRepository->getWebOwningShipSystem($tholianWeb->getId()); |
|
50
|
|
|
if ($owningSpacecraftSystem === null) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
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