|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
10
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
11
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
12
|
|
|
use Doctrine\ORM\Mapping\OneToOne; |
|
13
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
14
|
|
|
use Override; |
|
|
|
|
|
|
15
|
|
|
use Stu\Component\Crew\CrewPositionEnum; |
|
16
|
|
|
use Stu\Module\Spacecraft\Lib\Crew\EntityWithCrewAssignmentsInterface; |
|
17
|
|
|
use Stu\Orm\Repository\CrewAssignmentRepository; |
|
18
|
|
|
|
|
19
|
|
|
#[Table(name: 'stu_crew_assign')] |
|
20
|
|
|
#[Entity(repositoryClass: CrewAssignmentRepository::class)] |
|
21
|
|
|
class CrewAssignment implements CrewAssignmentInterface |
|
22
|
|
|
{ |
|
23
|
|
|
#[Id] |
|
24
|
|
|
#[OneToOne(targetEntity: 'Crew')] |
|
25
|
|
|
#[JoinColumn(name: 'crew_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
26
|
|
|
private CrewInterface $crew; |
|
27
|
|
|
|
|
28
|
|
|
#[Column(type: 'smallint', enumType: CrewPositionEnum::class, nullable: true)] |
|
29
|
|
|
private ?CrewPositionEnum $position = null; |
|
30
|
|
|
|
|
31
|
|
|
#[ManyToOne(targetEntity: 'Spacecraft')] |
|
32
|
|
|
#[JoinColumn(name: 'spacecraft_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
33
|
|
|
private ?SpacecraftInterface $spacecraft = null; |
|
34
|
|
|
|
|
35
|
|
|
#[ManyToOne(targetEntity: 'Colony')] |
|
36
|
|
|
#[JoinColumn(name: 'colony_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
37
|
|
|
private ?ColonyInterface $colony = null; |
|
38
|
|
|
|
|
39
|
|
|
#[ManyToOne(targetEntity: 'TradePost')] |
|
40
|
|
|
#[JoinColumn(name: 'tradepost_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
41
|
|
|
private ?TradePostInterface $tradepost = null; |
|
42
|
|
|
|
|
43
|
|
|
#[ManyToOne(targetEntity: 'User')] |
|
44
|
|
|
#[JoinColumn(name: 'user_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
45
|
|
|
private UserInterface $user; |
|
46
|
|
|
|
|
47
|
|
|
#[ManyToOne(targetEntity: 'RepairTask')] |
|
48
|
|
|
#[JoinColumn(name: 'repair_task_id', referencedColumnName: 'id')] |
|
49
|
|
|
private ?RepairTaskInterface $repairTask = null; |
|
50
|
|
|
|
|
51
|
2 |
|
#[Override] |
|
52
|
|
|
public function getPosition(): ?CrewPositionEnum |
|
53
|
|
|
{ |
|
54
|
2 |
|
return $this->position ?? CrewPositionEnum::CREWMAN; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
#[Override] |
|
58
|
|
|
public function setPosition(?CrewPositionEnum $position): CrewAssignmentInterface |
|
59
|
|
|
{ |
|
60
|
|
|
$this->position = $position; |
|
61
|
|
|
|
|
62
|
|
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
#[Override] |
|
66
|
|
|
public function getUser(): UserInterface |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->user; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
#[Override] |
|
72
|
|
|
public function setUser(UserInterface $user): CrewAssignmentInterface |
|
73
|
|
|
{ |
|
74
|
|
|
$this->user = $user; |
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
#[Override] |
|
79
|
|
|
public function getRepairTask(): ?RepairTaskInterface |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->repairTask; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
#[Override] |
|
85
|
|
|
public function setRepairTask(?RepairTaskInterface $repairTask): CrewAssignmentInterface |
|
86
|
|
|
{ |
|
87
|
|
|
$this->repairTask = $repairTask; |
|
88
|
|
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
6 |
|
#[Override] |
|
92
|
|
|
public function getCrew(): CrewInterface |
|
93
|
|
|
{ |
|
94
|
6 |
|
return $this->crew; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
#[Override] |
|
98
|
|
|
public function setCrew(CrewInterface $crew): CrewAssignmentInterface |
|
99
|
|
|
{ |
|
100
|
|
|
$this->crew = $crew; |
|
101
|
|
|
|
|
102
|
|
|
return $this; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
#[Override] |
|
106
|
|
|
public function getSpacecraft(): ?SpacecraftInterface |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->spacecraft; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
#[Override] |
|
112
|
|
|
public function setSpacecraft(?SpacecraftInterface $spacecraft): CrewAssignmentInterface |
|
113
|
|
|
{ |
|
114
|
|
|
$this->spacecraft = $spacecraft; |
|
115
|
|
|
return $this; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
#[Override] |
|
119
|
|
|
public function getColony(): ?ColonyInterface |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->colony; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
#[Override] |
|
125
|
|
|
public function setColony(?ColonyInterface $colony): CrewAssignmentInterface |
|
126
|
|
|
{ |
|
127
|
|
|
$this->colony = $colony; |
|
128
|
|
|
|
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
#[Override] |
|
133
|
|
|
public function getTradepost(): ?TradePostInterface |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->tradepost; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
#[Override] |
|
139
|
|
|
public function setTradepost(?TradePostInterface $tradepost): CrewAssignmentInterface |
|
140
|
|
|
{ |
|
141
|
|
|
$this->tradepost = $tradepost; |
|
142
|
|
|
|
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
#[Override] |
|
147
|
|
|
public function getFightCapability(): int |
|
148
|
|
|
{ |
|
149
|
|
|
$position = $this->getPosition() ?? CrewPositionEnum::CREWMAN; |
|
150
|
|
|
|
|
151
|
|
|
return $position->getFightCapability(); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
#[Override] |
|
155
|
|
|
public function clearAssignment(): CrewAssignmentInterface |
|
156
|
|
|
{ |
|
157
|
|
|
if ($this->spacecraft !== null) { |
|
158
|
|
|
$this->spacecraft->getCrewAssignments()->removeElement($this); |
|
159
|
|
|
} |
|
160
|
|
|
if ($this->colony !== null) { |
|
161
|
|
|
$this->colony->getCrewAssignments()->removeElement($this); |
|
162
|
|
|
} |
|
163
|
|
|
if ($this->tradepost !== null) { |
|
164
|
|
|
$this->tradepost->getCrewAssignments()->removeElement($this); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
$this->spacecraft = null; |
|
168
|
|
|
$this->colony = null; |
|
169
|
|
|
$this->tradepost = null; |
|
170
|
|
|
|
|
171
|
|
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
#[Override] |
|
175
|
|
|
public function assign(EntityWithCrewAssignmentsInterface $target): CrewAssignmentInterface |
|
176
|
|
|
{ |
|
177
|
|
|
if ($target instanceof ColonyInterface) { |
|
178
|
|
|
$this->setColony($target); |
|
179
|
|
|
} |
|
180
|
|
|
if ($target instanceof SpacecraftInterface) { |
|
181
|
|
|
$this->setSpacecraft($target); |
|
182
|
|
|
} |
|
183
|
|
|
if ($target instanceof TradePostInterface) { |
|
184
|
|
|
$this->setTradepost($target); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
return $this; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
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