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\GeneratedValue; |
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
12
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
13
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
14
|
|
|
use Doctrine\ORM\Mapping\Table; |
15
|
|
|
use Doctrine\ORM\Mapping\UniqueConstraint; |
16
|
|
|
use Override; |
|
|
|
|
17
|
|
|
use Stu\Component\Crew\CrewEnum; |
|
|
|
|
18
|
|
|
use Stu\Module\Spacecraft\Lib\Crew\EntityWithCrewAssignmentsInterface; |
19
|
|
|
use Stu\Orm\Repository\CrewAssignmentRepository; |
20
|
|
|
|
21
|
|
|
//TODO RENAME to CrewAssignment, indices, repo and stuff |
22
|
|
|
#[Table(name: 'stu_crew_assign')] |
23
|
|
|
#[Index(name: 'ship_crew_colony_idx', columns: ['colony_id'])] |
24
|
|
|
#[Index(name: 'ship_crew_spacecraft_idx', columns: ['spacecraft_id'])] |
25
|
|
|
#[Index(name: 'ship_crew_tradepost_idx', columns: ['tradepost_id'])] |
26
|
|
|
#[Index(name: 'ship_crew_user_idx', columns: ['user_id'])] |
27
|
|
|
#[UniqueConstraint(name: 'ship_crew_crew_idx', columns: ['crew_id'])] |
28
|
|
|
#[Entity(repositoryClass: CrewAssignmentRepository::class)] |
29
|
|
|
class CrewAssignment implements CrewAssignmentInterface |
30
|
|
|
{ |
31
|
|
|
#[Id] |
32
|
|
|
#[Column(type: 'integer')] |
33
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
34
|
|
|
private int $id; |
35
|
|
|
|
36
|
|
|
#[Column(type: 'integer', nullable: true)] |
37
|
|
|
private ?int $spacecraft_id = 0; |
38
|
|
|
|
39
|
|
|
#[Column(type: 'integer', nullable: true)] |
40
|
|
|
private ?int $colony_id = null; |
|
|
|
|
41
|
|
|
|
42
|
|
|
#[Column(type: 'integer', nullable: true)] |
43
|
|
|
private ?int $tradepost_id = null; |
|
|
|
|
44
|
|
|
|
45
|
|
|
#[Column(type: 'integer')] |
46
|
|
|
private int $crew_id = 0; |
47
|
|
|
|
48
|
|
|
#[Column(type: 'smallint', nullable: true)] |
49
|
|
|
private ?int $slot = null; |
50
|
|
|
|
51
|
|
|
#[Column(type: 'integer')] |
52
|
|
|
private int $user_id = 0; |
53
|
|
|
|
54
|
|
|
#[Column(type: 'integer', nullable: true)] |
55
|
|
|
private ?int $repair_task_id = null; |
|
|
|
|
56
|
|
|
|
57
|
|
|
#[ManyToOne(targetEntity: 'Crew')] |
58
|
|
|
#[JoinColumn(name: 'crew_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
59
|
|
|
private CrewInterface $crew; |
60
|
|
|
|
61
|
|
|
#[ManyToOne(targetEntity: 'Spacecraft')] |
62
|
|
|
#[JoinColumn(name: 'spacecraft_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
63
|
|
|
private ?SpacecraftInterface $spacecraft = null; |
64
|
|
|
|
65
|
|
|
#[ManyToOne(targetEntity: 'Colony')] |
66
|
|
|
#[JoinColumn(name: 'colony_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
67
|
|
|
private ?ColonyInterface $colony = null; |
68
|
|
|
|
69
|
|
|
#[ManyToOne(targetEntity: 'TradePost')] |
70
|
|
|
#[JoinColumn(name: 'tradepost_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
71
|
|
|
private ?TradePostInterface $tradepost = null; |
72
|
|
|
|
73
|
|
|
#[ManyToOne(targetEntity: 'User')] |
74
|
|
|
#[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
75
|
|
|
private UserInterface $user; |
76
|
|
|
|
77
|
|
|
#[ManyToOne(targetEntity: 'RepairTask')] |
78
|
|
|
#[JoinColumn(name: 'repair_task_id', referencedColumnName: 'id')] |
79
|
|
|
private ?RepairTaskInterface $repairTask = null; |
80
|
|
|
|
81
|
1 |
|
#[Override] |
82
|
|
|
public function getId(): int |
83
|
|
|
{ |
84
|
1 |
|
return $this->id; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
#[Override] |
88
|
|
|
public function getCrewId(): int |
89
|
|
|
{ |
90
|
|
|
return $this->crew_id; |
91
|
|
|
} |
92
|
|
|
|
93
|
2 |
|
#[Override] |
94
|
|
|
public function getSlot(): ?int |
95
|
|
|
{ |
96
|
2 |
|
return $this->slot; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
#[Override] |
100
|
|
|
public function setSlot(?int $slot): CrewAssignmentInterface |
101
|
|
|
{ |
102
|
|
|
$this->slot = $slot; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
1 |
|
#[Override] |
108
|
|
|
public function getPosition(): string |
109
|
|
|
{ |
110
|
1 |
|
return CrewEnum::getDescription($this->getSlot()); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
#[Override] |
114
|
|
|
public function getUserId(): int |
115
|
|
|
{ |
116
|
|
|
return $this->user_id; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
#[Override] |
120
|
|
|
public function getUser(): UserInterface |
121
|
|
|
{ |
122
|
|
|
return $this->user; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
#[Override] |
126
|
|
|
public function setUser(UserInterface $user): CrewAssignmentInterface |
127
|
|
|
{ |
128
|
|
|
$this->user = $user; |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
#[Override] |
133
|
|
|
public function getRepairTask(): ?RepairTaskInterface |
134
|
|
|
{ |
135
|
|
|
return $this->repairTask; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
#[Override] |
139
|
|
|
public function setRepairTask(?RepairTaskInterface $repairTask): CrewAssignmentInterface |
140
|
|
|
{ |
141
|
|
|
$this->repairTask = $repairTask; |
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
5 |
|
#[Override] |
146
|
|
|
public function getCrew(): CrewInterface |
147
|
|
|
{ |
148
|
5 |
|
return $this->crew; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
#[Override] |
152
|
|
|
public function setCrew(CrewInterface $crew): CrewAssignmentInterface |
153
|
|
|
{ |
154
|
|
|
$this->crew = $crew; |
155
|
|
|
|
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
#[Override] |
160
|
|
|
public function getSpacecraft(): ?SpacecraftInterface |
161
|
|
|
{ |
162
|
|
|
return $this->spacecraft; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
#[Override] |
166
|
|
|
public function setSpacecraft(?SpacecraftInterface $spacecraft): CrewAssignmentInterface |
167
|
|
|
{ |
168
|
|
|
$this->spacecraft_id = null; |
169
|
|
|
$this->spacecraft = $spacecraft; |
170
|
|
|
return $this; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
#[Override] |
174
|
|
|
public function getColony(): ?ColonyInterface |
175
|
|
|
{ |
176
|
|
|
return $this->colony; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
#[Override] |
180
|
|
|
public function setColony(?ColonyInterface $colony): CrewAssignmentInterface |
181
|
|
|
{ |
182
|
|
|
$this->colony = $colony; |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
#[Override] |
188
|
|
|
public function getTradepost(): ?TradePostInterface |
189
|
|
|
{ |
190
|
|
|
return $this->tradepost; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
#[Override] |
194
|
|
|
public function setTradepost(?TradePostInterface $tradepost): CrewAssignmentInterface |
195
|
|
|
{ |
196
|
|
|
$this->tradepost = $tradepost; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
#[Override] |
202
|
|
|
public function clearAssignment(): CrewAssignmentInterface |
203
|
|
|
{ |
204
|
|
|
if ($this->spacecraft !== null) { |
205
|
|
|
$this->spacecraft->getCrewAssignments()->removeElement($this); |
206
|
|
|
} |
207
|
|
|
if ($this->colony !== null) { |
208
|
|
|
$this->colony->getCrewAssignments()->removeElement($this); |
209
|
|
|
} |
210
|
|
|
if ($this->tradepost !== null) { |
211
|
|
|
$this->tradepost->getCrewAssignments()->removeElement($this); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
$this->spacecraft = null; |
215
|
|
|
$this->colony = null; |
216
|
|
|
$this->tradepost = null; |
217
|
|
|
|
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
#[Override] |
222
|
|
|
public function assign(EntityWithCrewAssignmentsInterface $target): CrewAssignmentInterface |
223
|
|
|
{ |
224
|
|
|
if ($target instanceof ColonyInterface) { |
225
|
|
|
$this->setColony($target); |
226
|
|
|
} |
227
|
|
|
if ($target instanceof SpacecraftInterface) { |
228
|
|
|
$this->setSpacecraft($target); |
229
|
|
|
} |
230
|
|
|
if ($target instanceof TradePostInterface) { |
231
|
|
|
$this->setTradepost($target); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|
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