|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\SourceAndTargetWrappersInterface; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftLoaderInterface; |
|
11
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
12
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
13
|
|
|
|
|
14
|
|
|
final class ShipLoader implements ShipLoaderInterface |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param SpacecraftLoaderInterface<ShipWrapperInterface> $spacecraftLoader |
|
18
|
|
|
*/ |
|
19
|
1 |
|
public function __construct( |
|
20
|
|
|
private SpacecraftLoaderInterface $spacecraftLoader |
|
21
|
1 |
|
) {} |
|
22
|
|
|
|
|
23
|
2 |
|
#[Override] |
|
24
|
|
|
public function getByIdAndUser( |
|
25
|
|
|
int $shipId, |
|
26
|
|
|
int $userId, |
|
27
|
|
|
bool $allowUplink = false, |
|
28
|
|
|
bool $checkForEntityLock = true |
|
29
|
|
|
): ShipInterface { |
|
30
|
|
|
|
|
31
|
2 |
|
$spacecraft = $this->spacecraftLoader->getByIdAndUser( |
|
32
|
2 |
|
$shipId, |
|
33
|
2 |
|
$userId, |
|
34
|
2 |
|
$allowUplink, |
|
35
|
2 |
|
$checkForEntityLock |
|
36
|
2 |
|
); |
|
37
|
|
|
|
|
38
|
2 |
|
if (!$spacecraft instanceof ShipInterface) { |
|
39
|
|
|
throw new RuntimeException(sprintf('shipId %d is not a ship', $shipId)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
2 |
|
return $spacecraft; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
#[Override] |
|
46
|
|
|
public function getWrapperByIdAndUser( |
|
47
|
|
|
int $shipId, |
|
48
|
|
|
int $userId, |
|
49
|
|
|
bool $allowUplink = false, |
|
50
|
|
|
bool $checkForEntityLock = true |
|
51
|
|
|
): ShipWrapperInterface { |
|
52
|
|
|
|
|
53
|
|
|
$wrapper = $this->spacecraftLoader->getWrapperByIdAndUser( |
|
54
|
|
|
$shipId, |
|
55
|
|
|
$userId, |
|
56
|
|
|
$allowUplink, |
|
57
|
|
|
$checkForEntityLock |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
if (!$wrapper instanceof ShipWrapperInterface) { |
|
61
|
|
|
throw new RuntimeException(sprintf('shipId %d is not a ship', $shipId)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $wrapper; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
#[Override] |
|
68
|
|
|
public function getWrappersBySourceAndUserAndTarget( |
|
69
|
|
|
int $shipId, |
|
70
|
|
|
int $userId, |
|
71
|
|
|
int $targetId, |
|
72
|
|
|
bool $allowUplink = false, |
|
73
|
|
|
bool $checkForEntityLock = true |
|
74
|
|
|
): SourceAndTargetWrappersInterface { |
|
75
|
|
|
|
|
76
|
|
|
return $this->spacecraftLoader->getWrappersBySourceAndUserAndTarget( |
|
77
|
|
|
$shipId, |
|
78
|
|
|
$userId, |
|
79
|
|
|
$targetId, |
|
80
|
|
|
$allowUplink, |
|
81
|
|
|
$checkForEntityLock |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
#[Override] |
|
86
|
|
|
public function find(int $shipId, bool $checkForEntityLock = true): ?ShipWrapperInterface |
|
87
|
|
|
{ |
|
88
|
|
|
$wrapper = $this->spacecraftLoader->find( |
|
89
|
|
|
$shipId, |
|
90
|
|
|
$checkForEntityLock |
|
91
|
|
|
); |
|
92
|
|
|
|
|
93
|
|
|
if ($wrapper !== null && !$wrapper instanceof ShipWrapperInterface) { |
|
94
|
|
|
throw new RuntimeException(sprintf('shipId %d is not a ship', $shipId)); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return $wrapper; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function save(SpacecraftInterface $ship): void |
|
101
|
|
|
{ |
|
102
|
|
|
$this->spacecraftLoader->save($ship); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
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