|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cv\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Auth\Entity\InfoInterface; |
|
6
|
|
|
use Auth\Entity\UserInterface; |
|
7
|
|
|
use Core\Collection\IdentityWrapper; |
|
8
|
|
|
use Core\Entity\AbstractIdentifiableEntity; |
|
9
|
|
|
use Core\Entity\DraftableEntityInterface; |
|
10
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
11
|
|
|
use Doctrine\Common\Collections\Collection as CollectionInterface; |
|
12
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Defines CV Model |
|
16
|
|
|
* |
|
17
|
|
|
* @ODM\Document(collection="cvs", repositoryClass="\Cv\Repository\Cv") |
|
18
|
|
|
* @ODM\Indexes({ |
|
19
|
|
|
* @ODM\Index(keys={ |
|
20
|
|
|
* "preferredJob.desiredJob"="text" |
|
21
|
|
|
* },name="cvFulltext") |
|
22
|
|
|
* }) |
|
23
|
|
|
*/ |
|
24
|
|
|
class Cv extends AbstractIdentifiableEntity implements CvInterface, DraftableEntityInterface |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Owner of the CV |
|
29
|
|
|
* |
|
30
|
|
|
* @var UserInterface |
|
31
|
|
|
* @ODM\ReferenceOne(targetDocument="\Auth\Entity\User", simple=true, cascade="persist") |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $user; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* personal informations, contains firstname, lastname, email, |
|
37
|
|
|
* phone etc. |
|
38
|
|
|
* |
|
39
|
|
|
* @ODM\EmbedOne(targetDocument="Contact") |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $contact; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Education History |
|
45
|
|
|
* |
|
46
|
|
|
* @var ArrayCollection |
|
47
|
|
|
* @ODM\EmbedMany(targetDocument="\Cv\Entity\Education") |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $educations; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Employment History |
|
53
|
|
|
* |
|
54
|
|
|
* @var ArrayCollection |
|
55
|
|
|
* @ODM\EmbedMany(targetDocument="\Cv\Entity\Employment") |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $employments; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Skills |
|
61
|
|
|
* |
|
62
|
|
|
* @var ArrayCollection |
|
63
|
|
|
* @ODM\EmbedMany(targetDocument="\Cv\Entity\Skill") |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $skills; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Skills |
|
69
|
|
|
* |
|
70
|
|
|
* @var ArrayCollection |
|
71
|
|
|
* @ODM\EmbedMany(targetDocument="\Cv\Entity\Language") |
|
72
|
|
|
*/ |
|
73
|
|
|
protected $languageSkills; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @var array |
|
77
|
|
|
* @ODM\Collection |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $nativeLanguages=[]; |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Preferred Job. Where do the user want to work? What kind of work he wants do do |
|
84
|
|
|
* |
|
85
|
|
|
* @ODM\EmbedOne(targetDocument="\Cv\Entity\PreferredJob") |
|
86
|
|
|
*/ |
|
87
|
|
|
protected $preferredJob; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Flag indicating draft state of this cv. |
|
91
|
|
|
* |
|
92
|
|
|
* @var bool |
|
93
|
|
|
* @ODM\Boolean |
|
94
|
|
|
*/ |
|
95
|
|
|
protected $isDraft = false; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Status |
|
99
|
|
|
* |
|
100
|
|
|
* @var Status |
|
101
|
|
|
* @ODM\EmbedOne(targetDocument="Status") |
|
102
|
|
|
* @ODM\Index |
|
103
|
|
|
*/ |
|
104
|
|
|
protected $status; |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Multiple attachments |
|
108
|
|
|
* |
|
109
|
|
|
* @since 0.26 |
|
110
|
|
|
* @ODM\ReferenceMany(targetDocument="Attachment", simple="true", cascade={"persist", "remove"}) |
|
111
|
|
|
*/ |
|
112
|
|
|
protected $attachments; |
|
113
|
|
|
|
|
114
|
|
|
public function __construct() |
|
115
|
|
|
{ |
|
116
|
|
|
$this->status = new Status(); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return UserInterface |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getUser() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->user; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @param UserInterface $user |
|
129
|
|
|
* @return $this |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setUser(UserInterface $user) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->user = $user; |
|
134
|
|
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return Contact |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getContact() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->contact; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return Cv |
|
147
|
|
|
*/ |
|
148
|
|
|
public function setContact(InfoInterface $contact) |
|
149
|
|
|
{ |
|
150
|
|
|
if (!$contact instanceof Contact) { |
|
151
|
|
|
$contact = new Contact($contact); |
|
152
|
|
|
} |
|
153
|
|
|
$this->contact = $contact; |
|
154
|
|
|
return $this; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return ArrayCollection |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getEducations() |
|
161
|
|
|
{ |
|
162
|
|
|
if (!$this->educations) { |
|
163
|
|
|
$this->setEducations(new ArrayCollection()); |
|
164
|
|
|
} |
|
165
|
|
|
return $this->educations; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @return ArrayCollection |
|
|
|
|
|
|
170
|
|
|
*/ |
|
171
|
|
|
public function getEducationsIndexedById() |
|
172
|
|
|
{ |
|
173
|
|
|
return new IdentityWrapper($this->getEducations()); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param CollectionInterface $educations |
|
178
|
|
|
* @return $this |
|
179
|
|
|
*/ |
|
180
|
|
|
public function setEducations(CollectionInterface $educations) |
|
181
|
|
|
{ |
|
182
|
|
|
$this->educations = $educations; |
|
|
|
|
|
|
183
|
|
|
return $this; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @return ArrayCollection |
|
188
|
|
|
*/ |
|
189
|
|
|
public function getEmployments() |
|
190
|
|
|
{ |
|
191
|
|
|
if (!$this->employments) { |
|
192
|
|
|
$this->setEmployments(new ArrayCollection()); |
|
193
|
|
|
} |
|
194
|
|
|
return $this->employments; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @return ArrayCollection |
|
|
|
|
|
|
199
|
|
|
*/ |
|
200
|
|
|
public function getEmploymentsIndexedById() |
|
201
|
|
|
{ |
|
202
|
|
|
return new IdentityWrapper($this->getEmployments()); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @param CollectionInterface $employments |
|
207
|
|
|
* @return $this |
|
208
|
|
|
*/ |
|
209
|
|
|
public function setEmployments(CollectionInterface $employments) |
|
210
|
|
|
{ |
|
211
|
|
|
$this->employments = $employments; |
|
|
|
|
|
|
212
|
|
|
return $this; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @return ArrayCollection |
|
217
|
|
|
*/ |
|
218
|
|
|
public function getSkills() |
|
219
|
|
|
{ |
|
220
|
|
|
if (!$this->skills) { |
|
221
|
|
|
$this->setSkills(new ArrayCollection()); |
|
222
|
|
|
} |
|
223
|
|
|
return $this->skills; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @return ArrayCollection |
|
|
|
|
|
|
228
|
|
|
*/ |
|
229
|
|
|
public function getSkillsIndexedById() |
|
230
|
|
|
{ |
|
231
|
|
|
return new IdentityWrapper($this->getSkills()); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* @param CollectionInterface $skills |
|
236
|
|
|
* @return $this |
|
237
|
|
|
*/ |
|
238
|
|
|
public function setSkills(CollectionInterface $skills) |
|
239
|
|
|
{ |
|
240
|
|
|
$this->skills = $skills; |
|
|
|
|
|
|
241
|
|
|
return $this; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* @param bool $isDraft |
|
246
|
|
|
* @return $this |
|
247
|
|
|
*/ |
|
248
|
|
|
public function setIsDraft($isDraft) |
|
249
|
|
|
{ |
|
250
|
|
|
$this->isDraft=$isDraft; |
|
251
|
|
|
return $this; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @return boolean |
|
256
|
|
|
*/ |
|
257
|
|
|
public function isDraft() |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->isDraft; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* @return \Cv\Entity\PreferredJobInterface |
|
264
|
|
|
*/ |
|
265
|
|
|
public function getPreferredJob() |
|
266
|
|
|
{ |
|
267
|
|
|
if (null == $this->preferredJob) { |
|
268
|
|
|
$this->preferredJob = new PreferredJob(); |
|
269
|
|
|
} |
|
270
|
|
|
return $this->preferredJob; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @param \Cv\Entity\PreferredJobInterface $preferredJob |
|
275
|
|
|
* @return $this |
|
276
|
|
|
*/ |
|
277
|
|
|
public function setPreferredJob(PreferredJobInterface $preferredJob) |
|
278
|
|
|
{ |
|
279
|
|
|
$this->preferredJob = $preferredJob; |
|
280
|
|
|
return $this; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* @return ArrayCollection |
|
285
|
|
|
*/ |
|
286
|
|
|
public function getLanguageSkills() |
|
287
|
|
|
{ |
|
288
|
|
|
if (!$this->languageSkills) { |
|
289
|
|
|
$this->setLanguageSkills(new ArrayCollection()); |
|
290
|
|
|
} |
|
291
|
|
|
return $this->languageSkills; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
/** |
|
295
|
|
|
* @param CollectionInterface $languageSkills |
|
296
|
|
|
* @return $this |
|
297
|
|
|
*/ |
|
298
|
|
|
public function setLanguageSkills(CollectionInterface $languageSkills) |
|
299
|
|
|
{ |
|
300
|
|
|
$this->languageSkills = $languageSkills; |
|
|
|
|
|
|
301
|
|
|
return $this; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* @return ArrayCollection |
|
|
|
|
|
|
306
|
|
|
*/ |
|
307
|
|
|
public function getLanguageSkillsIndexedById() |
|
308
|
|
|
{ |
|
309
|
|
|
return new IdentityWrapper($this->getLanguageSkills()); |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* Sets the mothers tongue of the candidate |
|
314
|
|
|
* |
|
315
|
|
|
* @param array |
|
316
|
|
|
* @return $this |
|
317
|
|
|
*/ |
|
318
|
|
|
public function setNativeLanguages($nativeLanguages) |
|
319
|
|
|
{ |
|
320
|
|
|
$this->nativeLanguages=$nativeLanguages; |
|
321
|
|
|
return $this; |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* Gets the mothers tongue of the candidate |
|
326
|
|
|
* |
|
327
|
|
|
* @return string |
|
|
|
|
|
|
328
|
|
|
*/ |
|
329
|
|
|
public function getNativeLanguages() |
|
330
|
|
|
{ |
|
331
|
|
|
return $this->nativeLanguages; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* @return Status |
|
336
|
|
|
*/ |
|
337
|
|
|
public function getStatus() |
|
338
|
|
|
{ |
|
339
|
|
|
if (!isset($this->status)) { |
|
340
|
|
|
$this->status = new Status(); |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
return $this->status; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* @param Status|string $status |
|
348
|
|
|
*/ |
|
349
|
|
|
public function setStatus($status) |
|
350
|
|
|
{ |
|
351
|
|
|
if (!$status instanceof Status) { |
|
352
|
|
|
$status = new Status($status); |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
$this->status = $status; |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
/** |
|
359
|
|
|
* @param CollectionInterface $attachments |
|
360
|
|
|
* @return Cv |
|
361
|
|
|
* @since 0.26 |
|
362
|
|
|
*/ |
|
363
|
|
|
public function setAttachments(CollectionInterface $attachments) |
|
364
|
|
|
{ |
|
365
|
|
|
$this->attachments = $attachments; |
|
366
|
|
|
return $this; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* @return CollectionInterface |
|
371
|
|
|
* @since 0.26 |
|
372
|
|
|
*/ |
|
373
|
|
|
public function getAttachments() |
|
374
|
|
|
{ |
|
375
|
|
|
if (!$this->attachments) { |
|
376
|
|
|
$this->setAttachments(new ArrayCollection()); |
|
377
|
|
|
} |
|
378
|
|
|
return $this->attachments; |
|
379
|
|
|
} |
|
380
|
|
|
} |
|
381
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.