1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @filesource |
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
7
|
|
|
* @license MIT |
8
|
|
|
* @author [email protected] |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Jobs\Entity; |
12
|
|
|
|
13
|
|
|
use Core\Entity\AbstractIdentifiableEntity; |
14
|
|
|
use Core\Entity\Collection\ArrayCollection; |
15
|
|
|
use Core\Entity\DraftableEntityInterface; |
16
|
|
|
use Core\Entity\MetaDataProviderTrait; |
17
|
|
|
use Core\Entity\Permissions; |
18
|
|
|
use Core\Entity\Snapshot as BaseEntity; |
19
|
|
|
use Auth\Entity\UserInterface; |
20
|
|
|
use Core\Entity\SnapshotAttributesProviderInterface; |
21
|
|
|
use Core\Entity\SnapshotTrait; |
22
|
|
|
use DateTime; |
23
|
|
|
use Doctrine\Common\Collections\Collection; |
24
|
|
|
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs; |
25
|
|
|
use Exception; |
26
|
|
|
use InvalidArgumentException; |
27
|
|
|
use Organizations\Entity\OrganizationInterface; |
28
|
|
|
use Core\Exception\ImmutablePropertyException; |
29
|
|
|
use Core\Entity\PermissionsInterface; |
30
|
|
|
use Organizations\Entity\Organization; |
31
|
|
|
use Core\Entity\SnapshotInterface; |
32
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
33
|
|
|
use Core\Entity\EntityInterface; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* by using the BaseEntity, |
37
|
|
|
* |
38
|
|
|
* Class JobSnapshot |
39
|
|
|
* @package Jobs\Entity |
40
|
|
|
* |
41
|
|
|
* @ODM\Document(collection="jobs.snapshots2", repositoryClass="Core\Repository\SnapshotRepository") |
42
|
|
|
*/ |
43
|
|
|
class JobSnapshot extends Job implements SnapshotInterface, SnapshotAttributesProviderInterface |
44
|
|
|
{ |
45
|
|
|
use SnapshotTrait; |
46
|
|
|
|
47
|
|
|
const SNAPSHOTMETA_ENTITY_CLASS = JobSnapshotMeta::class; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @ODM\ReferenceOne(targetDocument="\Jobs\Entity\Job", inversedBy="snapshots", storeAs="id") |
52
|
|
|
* @var JobSnapshotMeta |
53
|
|
|
*/ |
54
|
|
|
private $snapshotEntity; |
55
|
|
|
|
56
|
|
|
protected $snapshotAttributes = [ |
57
|
|
|
'title', 'company', 'organization', 'contactEmail', 'language', |
58
|
|
|
'location', 'locations', 'link', 'datePublishStart', 'datePublishEnd', |
59
|
|
|
'reference', 'atsEnabled', 'template', 'uriApply', 'templateValues', |
60
|
|
|
'classifications', 'atsMode', 'metaData', |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
private $snapshotDiffSpecs = [ |
64
|
|
|
'title', |
65
|
|
|
'company', |
66
|
|
|
'organization', |
67
|
|
|
'locations' => [ |
68
|
|
|
'city', 'region', 'postalcode', 'country' |
69
|
|
|
], |
70
|
|
|
'templateValues' => [ |
71
|
|
|
'qualifications' |
72
|
|
|
], |
73
|
|
|
]; |
74
|
|
|
|
75
|
|
|
public function getId() |
76
|
|
|
{ |
77
|
|
|
return $this->proxy('getId'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getSnapshotId() |
81
|
|
|
{ |
82
|
|
|
return $this->id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getSnapshotDraft() |
86
|
|
|
{ |
87
|
|
|
return $this->proxy('getSnapshotDraft'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function hasSnapshotDraft() |
91
|
|
|
{ |
92
|
|
|
return $this->proxy('hasSnapshotDraft'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getResourceId() |
96
|
|
|
{ |
97
|
|
|
return $this->proxy('getResourceId'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function setApplyId($applyId) |
101
|
|
|
{ |
102
|
|
|
$this->immutable('applyId'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getApplyId() |
106
|
|
|
{ |
107
|
|
|
return $this->proxy('getApplyId'); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function setUser(UserInterface $user) |
111
|
|
|
{ |
112
|
|
|
$this->immutable('user'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getUser() |
116
|
|
|
{ |
117
|
|
|
return $this->proxy('getUser'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function unsetUser($removePermissions = true) |
121
|
|
|
{ |
122
|
|
|
$this->immutable('user'); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function setApplications(Collection $applications) |
126
|
|
|
{ |
127
|
|
|
$this->immutable('applications'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getApplications() |
131
|
|
|
{ |
132
|
|
|
return $this->proxy('getApplications'); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getUnreadApplications() |
136
|
|
|
{ |
137
|
|
|
return $this->proxy('getUnreadApplications'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
public function changeStatus($status, $message = '[System]') |
142
|
|
|
{ |
143
|
|
|
$this->immutable('status'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function getStatus() |
147
|
|
|
{ |
148
|
|
|
return $this->proxyClone('getStatus'); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setStatus($status) |
152
|
|
|
{ |
153
|
|
|
$this->immutable('status'); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function setHistory(Collection $history) |
157
|
|
|
{ |
158
|
|
|
$this->immutable('history'); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function getHistory() |
162
|
|
|
{ |
163
|
|
|
return $this->proxy('getHistory'); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
public function setTermsAccepted($termsAccepted) |
167
|
|
|
{ |
168
|
|
|
$this->immutable('termsAccepted'); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function getTermsAccepted() |
172
|
|
|
{ |
173
|
|
|
return $this->proxyClone('getTermsAccepted'); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function getUriPublisher() |
177
|
|
|
{ |
178
|
|
|
return $this->proxy('getUriPublisher'); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function setUriPublisher($uriPublisher) |
182
|
|
|
{ |
183
|
|
|
$this->immutable('uriPublisher'); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function getPublisher($key) |
187
|
|
|
{ |
188
|
|
|
$this->inaccessible('publisher'); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
public function setPublisherReference($key, $reference) |
192
|
|
|
{ |
193
|
|
|
$this->immutable('publisherReference'); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
public function getPermissions() |
197
|
|
|
{ |
198
|
|
|
if (!$this->permissions) { |
199
|
|
|
$originalPermissions = $this->getOriginalEntity()->getPermissions(); |
200
|
|
|
$permissions = new Permissions('Job/Permissions'); |
201
|
|
|
$permissions->inherit($originalPermissions); |
202
|
|
|
$this->permissions = $permissions; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
return clone $this->permissions; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function setPermissions(PermissionsInterface $permissions) |
209
|
|
|
{ |
210
|
|
|
$this->immutable('permissions'); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
public function setPortals(array $portals) |
214
|
|
|
{ |
215
|
|
|
$this->immutable('portals'); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function getPortals() |
219
|
|
|
{ |
220
|
|
|
return $this->proxyClone('getPortals'); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function isActive() |
224
|
|
|
{ |
225
|
|
|
return $this->proxy('isActive'); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function getDateCreated() |
229
|
|
|
{ |
230
|
|
|
return $this->proxyClone('getDateCreated'); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
public function setDateCreated($dateCreated = null) |
234
|
|
|
{ |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function getDateModified() |
238
|
|
|
{ |
239
|
|
|
return $this->proxyClone('getDateModified'); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
public function setDateModified($dateModified = null) |
243
|
|
|
{ |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
public function __toString() |
247
|
|
|
{ |
248
|
|
|
return self::class . '( ' . $this->getSnapshotId() . ' )'; |
249
|
|
|
} |
250
|
|
|
} |
251
|
|
|
|