|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* apparat-object |
|
5
|
|
|
* |
|
6
|
|
|
* @category Apparat |
|
7
|
|
|
* @package Apparat\Object |
|
8
|
|
|
* @subpackage Apparat\Object\Domain |
|
9
|
|
|
* @author Joschi Kuphal <[email protected]> / @jkphl |
|
10
|
|
|
* @copyright Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl |
|
11
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License (MIT) |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
/*********************************************************************************** |
|
15
|
|
|
* The MIT License (MIT) |
|
16
|
|
|
* |
|
17
|
|
|
* Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl |
|
18
|
|
|
* |
|
19
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
20
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
|
21
|
|
|
* the Software without restriction, including without limitation the rights to |
|
22
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
23
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so, |
|
24
|
|
|
* subject to the following conditions: |
|
25
|
|
|
* |
|
26
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
27
|
|
|
* copies or substantial portions of the Software. |
|
28
|
|
|
* |
|
29
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
30
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
31
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
32
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
33
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
34
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
35
|
|
|
***********************************************************************************/ |
|
36
|
|
|
|
|
37
|
|
|
namespace Apparat\Object\Domain\Model\Object; |
|
38
|
|
|
|
|
39
|
|
|
use Apparat\Kernel\Ports\Kernel; |
|
40
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\DomainPropertiesTrait; |
|
41
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\IterableTrait; |
|
42
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\MetaPropertiesTrait; |
|
43
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\PayloadTrait; |
|
44
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\ProcessingInstructionsTrait; |
|
45
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\RelationsTrait; |
|
46
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\StatesTrait; |
|
47
|
|
|
use Apparat\Object\Domain\Model\Object\Traits\SystemPropertiesTrait; |
|
48
|
|
|
use Apparat\Object\Domain\Model\Properties\AbstractDomainProperties; |
|
49
|
|
|
use Apparat\Object\Domain\Model\Properties\InvalidArgumentException as PropertyInvalidArgumentException; |
|
50
|
|
|
use Apparat\Object\Domain\Model\Properties\MetaProperties; |
|
51
|
|
|
use Apparat\Object\Domain\Model\Properties\ProcessingInstructions; |
|
52
|
|
|
use Apparat\Object\Domain\Model\Properties\Relations; |
|
53
|
|
|
use Apparat\Object\Domain\Model\Properties\SystemProperties; |
|
54
|
|
|
use Apparat\Object\Domain\Model\Uri\RepositoryLocator; |
|
55
|
|
|
use Apparat\Object\Domain\Model\Uri\RepositoryLocatorInterface; |
|
56
|
|
|
use Apparat\Object\Domain\Repository\SelectorInterface; |
|
57
|
|
|
use Apparat\Object\Domain\Repository\Service; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Abstract object |
|
61
|
|
|
* |
|
62
|
|
|
* @package Apparat\Object |
|
63
|
|
|
* @subpackage Apparat\Object\Domain |
|
64
|
|
|
*/ |
|
65
|
|
|
abstract class AbstractObject implements ObjectInterface |
|
66
|
|
|
{ |
|
67
|
|
|
/** |
|
68
|
|
|
* Use traits |
|
69
|
|
|
*/ |
|
70
|
|
|
use SystemPropertiesTrait, MetaPropertiesTrait, DomainPropertiesTrait, RelationsTrait, |
|
71
|
|
|
ProcessingInstructionsTrait, PayloadTrait, IterableTrait, StatesTrait; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Repository locator |
|
75
|
|
|
* |
|
76
|
|
|
* @var RepositoryLocatorInterface |
|
77
|
|
|
*/ |
|
78
|
|
|
protected $locator; |
|
79
|
|
|
/** |
|
80
|
|
|
* Latest revision |
|
81
|
|
|
* |
|
82
|
|
|
* @var Revision |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $latestRevision; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Object constructor |
|
88
|
|
|
* |
|
89
|
|
|
* @param RepositoryLocatorInterface $locator Object repository locator |
|
90
|
|
|
* @param string $payload Object payload |
|
91
|
|
|
* @param array $propertyData Property data |
|
92
|
|
|
*/ |
|
93
|
47 |
|
public function __construct(RepositoryLocatorInterface $locator, $payload = '', array $propertyData = []) |
|
94
|
|
|
{ |
|
95
|
|
|
// If the domain property collection class is invalid |
|
96
|
47 |
|
if (!$this->domainPropertyCClass |
|
97
|
47 |
|
|| !class_exists($this->domainPropertyCClass) |
|
98
|
47 |
|
|| !(new \ReflectionClass($this->domainPropertyCClass))->isSubclassOf(AbstractDomainProperties::class) |
|
99
|
47 |
|
) { |
|
100
|
1 |
|
throw new PropertyInvalidArgumentException( |
|
101
|
1 |
|
sprintf( |
|
102
|
1 |
|
'Invalid domain property collection class "%s"', |
|
103
|
1 |
|
$this->domainPropertyCClass |
|
104
|
1 |
|
), |
|
105
|
|
|
PropertyInvalidArgumentException::INVALID_DOMAIN_PROPERTY_COLLECTION_CLASS |
|
106
|
1 |
|
); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Save the original object locator |
|
110
|
46 |
|
$this->locator = $locator; |
|
111
|
|
|
|
|
112
|
|
|
// Load the current revision data |
|
113
|
46 |
|
$this->loadRevisionData($payload, $propertyData); |
|
114
|
|
|
|
|
115
|
|
|
// Determine the latest revision number (considering a possible draft) |
|
116
|
45 |
|
$this->latestRevision = $this->hasDraft() |
|
117
|
45 |
|
? Kernel::create(Revision::class, [$this->getRevision()->getRevision() + 1, true]) |
|
118
|
45 |
|
: $this->getRevision(); |
|
119
|
|
|
|
|
120
|
|
|
// Update the object locator |
|
121
|
45 |
|
$this->updateLocator(); |
|
122
|
45 |
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Load object revision data |
|
126
|
|
|
* |
|
127
|
|
|
* @param string $payload Object payload |
|
128
|
|
|
* @param array $propertyData Property data |
|
129
|
|
|
*/ |
|
130
|
46 |
|
protected function loadRevisionData($payload = '', array $propertyData = []) |
|
131
|
|
|
{ |
|
132
|
46 |
|
$this->payload = $payload; |
|
133
|
|
|
|
|
134
|
|
|
// Instantiate the system properties |
|
135
|
46 |
|
$systemPropertyData = (empty($propertyData[SystemProperties::COLLECTION]) || |
|
136
|
46 |
|
!is_array( |
|
137
|
46 |
|
$propertyData[SystemProperties::COLLECTION] |
|
138
|
46 |
|
)) ? [] : $propertyData[SystemProperties::COLLECTION]; |
|
139
|
46 |
|
$this->systemProperties = Kernel::create(SystemProperties::class, [$systemPropertyData, $this]); |
|
140
|
|
|
|
|
141
|
|
|
// Instantiate the meta properties |
|
142
|
45 |
|
$metaPropertyData = (empty($propertyData[MetaProperties::COLLECTION]) || |
|
143
|
45 |
|
!is_array( |
|
144
|
45 |
|
$propertyData[MetaProperties::COLLECTION] |
|
145
|
45 |
|
)) ? [] : $propertyData[MetaProperties::COLLECTION]; |
|
146
|
|
|
/** @var MetaProperties $metaProperties */ |
|
147
|
45 |
|
$metaProperties = Kernel::create(MetaProperties::class, [$metaPropertyData, $this]); |
|
148
|
45 |
|
$this->setMetaProperties($metaProperties, true); |
|
149
|
|
|
|
|
150
|
|
|
// Instantiate the domain properties |
|
151
|
45 |
|
$domainPropertyData = (empty($propertyData[AbstractDomainProperties::COLLECTION]) || |
|
152
|
37 |
|
!is_array( |
|
153
|
37 |
|
$propertyData[AbstractDomainProperties::COLLECTION] |
|
154
|
45 |
|
)) ? [] : $propertyData[AbstractDomainProperties::COLLECTION]; |
|
155
|
|
|
/** @var AbstractDomainProperties $domainProperties */ |
|
156
|
45 |
|
$domainProperties = Kernel::create($this->domainPropertyCClass, [$domainPropertyData, $this]); |
|
157
|
45 |
|
$this->setDomainProperties($domainProperties, true); |
|
158
|
|
|
|
|
159
|
|
|
// Instantiate the processing instructions |
|
160
|
45 |
|
$procInstData = (empty($propertyData[ProcessingInstructions::COLLECTION]) || |
|
161
|
31 |
|
!is_array( |
|
162
|
31 |
|
$propertyData[ProcessingInstructions::COLLECTION] |
|
163
|
45 |
|
)) ? [] : $propertyData[ProcessingInstructions::COLLECTION]; |
|
164
|
|
|
/** @var ProcessingInstructions $procInstCollection */ |
|
165
|
45 |
|
$procInstCollection = Kernel::create(ProcessingInstructions::class, [$procInstData, $this]); |
|
166
|
45 |
|
$this->setProcessingInstructions($procInstCollection, true); |
|
167
|
|
|
|
|
168
|
|
|
// Instantiate the object relations |
|
169
|
45 |
|
$relationData = (empty($propertyData[Relations::COLLECTION]) || |
|
170
|
38 |
|
!is_array( |
|
171
|
38 |
|
$propertyData[Relations::COLLECTION] |
|
172
|
45 |
|
)) ? [] : $propertyData[Relations::COLLECTION]; |
|
173
|
|
|
/** @var Relations $relationCollection */ |
|
174
|
45 |
|
$relationCollection = Kernel::create(Relations::class, [$relationData, $this]); |
|
175
|
45 |
|
$this->setRelations($relationCollection, true); |
|
176
|
|
|
|
|
177
|
|
|
// Reset the object state |
|
178
|
45 |
|
$this->resetState(); |
|
179
|
45 |
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Return whether this object already has a draft revision |
|
183
|
|
|
* |
|
184
|
|
|
* @return bool Whether this object has a draft revision |
|
185
|
|
|
*/ |
|
186
|
45 |
|
protected function hasDraft() |
|
187
|
|
|
{ |
|
188
|
|
|
// Create the object draft resource locator |
|
189
|
45 |
|
$draftLocator = $this->locator->setRevision(Revision::current(true)); |
|
190
|
|
|
|
|
191
|
|
|
// Use the object manager to look for a draft resource |
|
192
|
|
|
/** @var ManagerInterface $objectManager */ |
|
193
|
45 |
|
$objectManager = Kernel::create(Service::class)->getObjectManager(); |
|
194
|
45 |
|
return $objectManager->objectResourceExists($draftLocator); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Update the object locator |
|
199
|
|
|
*/ |
|
200
|
45 |
|
protected function updateLocator() |
|
201
|
|
|
{ |
|
202
|
45 |
|
$revision = $this->getRevision(); |
|
203
|
45 |
|
$this->locator = $this->locator->setRevision( |
|
204
|
45 |
|
!$revision->isDraft() && ($this->getCurrentRevision()->getRevision() == $revision->getRevision()) |
|
205
|
45 |
|
? Revision::current($revision->isDraft()) |
|
206
|
34 |
|
: $revision |
|
207
|
45 |
|
)->setHidden($this->isDeleted()); |
|
208
|
45 |
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Return this object's current revision |
|
212
|
|
|
* |
|
213
|
|
|
* @return Revision Current revision |
|
214
|
|
|
*/ |
|
215
|
41 |
|
protected function getCurrentRevision() |
|
216
|
|
|
{ |
|
217
|
41 |
|
if ($this->latestRevision->isDraft() && ($this->latestRevision->getRevision() > 1)) { |
|
218
|
1 |
|
return Kernel::create(Revision::class, [$this->latestRevision->getRevision() - 1, false]); |
|
219
|
|
|
} |
|
220
|
41 |
|
return $this->latestRevision; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* Use a specific object revision |
|
225
|
|
|
* |
|
226
|
|
|
* @param Revision $revision Revision to be used |
|
227
|
|
|
* @return ObjectInterface Object |
|
228
|
|
|
* @throws OutOfBoundsException If a revision beyond the latest one is requested |
|
229
|
|
|
*/ |
|
230
|
40 |
|
public function useRevision(Revision $revision) |
|
231
|
|
|
{ |
|
232
|
|
|
// If a revision beyond the latest one is requested |
|
233
|
40 |
|
if (!$revision->isCurrent() && ($revision->getRevision() > $this->latestRevision->getRevision())) { |
|
234
|
1 |
|
throw new OutOfBoundsException( |
|
235
|
1 |
|
sprintf('Invalid object revision "%s"', $revision->getRevision()), |
|
236
|
|
|
OutOfBoundsException::INVALID_OBJECT_REVISION |
|
237
|
1 |
|
); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
// Determine whether the current revision was requested |
|
241
|
40 |
|
$currentRevision = $this->getCurrentRevision(); |
|
242
|
40 |
|
$isCurrentRevision = $revision->isCurrent() || $currentRevision->equals($revision); |
|
243
|
40 |
|
if ($isCurrentRevision) { |
|
244
|
40 |
|
$revision = $currentRevision; |
|
245
|
40 |
|
} |
|
246
|
|
|
|
|
247
|
|
|
// If the requested revision is not already used |
|
248
|
40 |
|
if (!$this->getRevision()->equals($revision)) { |
|
249
|
|
|
|
|
250
|
|
|
/** @var ManagerInterface $objectManager */ |
|
251
|
1 |
|
$objectManager = Kernel::create(Service::class)->getObjectManager(); |
|
252
|
|
|
/** @var Revision $newRevision */ |
|
253
|
1 |
|
$newRevision = $isCurrentRevision ? Revision::current() : $revision; |
|
254
|
|
|
/** @var RepositoryLocator $newRevisionLocator */ |
|
255
|
1 |
|
$newRevisionLocator = $this->locator->setRevision($newRevision); |
|
256
|
|
|
|
|
257
|
|
|
// Instantiate the requested revision resource |
|
258
|
1 |
|
$revisionResource = $objectManager->loadObjectResource($newRevisionLocator, SelectorInterface::ALL); |
|
259
|
|
|
|
|
260
|
|
|
// Load the revision resource data |
|
261
|
1 |
|
$this->loadRevisionData($revisionResource->getPayload(), $revisionResource->getPropertyData()); |
|
262
|
|
|
|
|
263
|
|
|
// Update the object locator |
|
264
|
1 |
|
$this->updateLocator(); |
|
265
|
1 |
|
} |
|
266
|
|
|
|
|
267
|
40 |
|
return $this; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* Return the object repository locator |
|
272
|
|
|
* |
|
273
|
|
|
* @return RepositoryLocatorInterface Object repository locator |
|
274
|
|
|
*/ |
|
275
|
47 |
|
public function getRepositoryLocator() |
|
276
|
|
|
{ |
|
277
|
47 |
|
return $this->locator; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* Return the object property data |
|
282
|
|
|
* |
|
283
|
|
|
* @param bool $serialize Serialize property objects |
|
284
|
|
|
* @return array Object property data |
|
285
|
|
|
*/ |
|
286
|
10 |
|
public function getPropertyData($serialize = true) |
|
287
|
|
|
{ |
|
288
|
10 |
|
$propertyData = array_filter([ |
|
289
|
10 |
|
SystemProperties::COLLECTION => $this->systemProperties->toArray($serialize), |
|
290
|
10 |
|
MetaProperties::COLLECTION => $this->metaProperties->toArray($serialize), |
|
291
|
10 |
|
AbstractDomainProperties::COLLECTION => $this->domainProperties->toArray($serialize), |
|
292
|
10 |
|
ProcessingInstructions::COLLECTION => $this->processingInstructions->toArray($serialize), |
|
293
|
10 |
|
Relations::COLLECTION => $this->relations->toArray($serialize), |
|
294
|
10 |
|
], function (array $collection) { |
|
295
|
10 |
|
return (boolean)count($collection); |
|
296
|
10 |
|
}); |
|
297
|
|
|
|
|
298
|
10 |
|
return $propertyData; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* Return the absolute object URL |
|
303
|
|
|
* |
|
304
|
|
|
* @return string |
|
305
|
|
|
*/ |
|
306
|
5 |
|
public function getAbsoluteUrl() |
|
307
|
|
|
{ |
|
308
|
5 |
|
return $this->locator->toRepositoryUrl(false, false); |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
/** |
|
312
|
|
|
* Return the canonical object URL |
|
313
|
|
|
* |
|
314
|
|
|
* @return string |
|
315
|
|
|
*/ |
|
316
|
1 |
|
public function getCanonicalUrl() |
|
317
|
|
|
{ |
|
318
|
1 |
|
return $this->locator->toRepositoryUrl(false, true); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Persist the current object revision |
|
323
|
|
|
* |
|
324
|
|
|
* @return ObjectInterface Object |
|
325
|
|
|
*/ |
|
326
|
5 |
|
public function persist() |
|
327
|
|
|
{ |
|
328
|
|
|
// If this is not the latest revision |
|
329
|
5 |
|
if ($this->getRevision()->getRevision() !== $this->latestRevision->getRevision()) { |
|
330
|
1 |
|
throw new RuntimeException( |
|
331
|
1 |
|
sprintf( |
|
332
|
1 |
|
'Cannot persist revision %s/%s', |
|
333
|
1 |
|
$this->getRevision()->getRevision(), |
|
334
|
1 |
|
$this->latestRevision->getRevision() |
|
335
|
1 |
|
), |
|
336
|
|
|
RuntimeException::CANNOT_PERSIST_EARLIER_REVISION |
|
337
|
1 |
|
); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
// Update the object repository |
|
341
|
5 |
|
$this->locator->getRepository()->updateObject($this); |
|
342
|
|
|
|
|
343
|
|
|
// Reset to a clean state |
|
344
|
3 |
|
$this->resetState(); |
|
345
|
3 |
|
$this->latestRevision = $this->getRevision(); |
|
346
|
3 |
|
$this->updateLocator(); |
|
347
|
|
|
|
|
348
|
|
|
// Post persistence hook |
|
349
|
3 |
|
$this->postPersist(); |
|
350
|
|
|
|
|
351
|
2 |
|
return $this; |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
/** |
|
355
|
|
|
* Post persistence hook |
|
356
|
|
|
* |
|
357
|
|
|
* @return void |
|
358
|
|
|
*/ |
|
359
|
3 |
|
protected function postPersist() |
|
360
|
|
|
{ |
|
361
|
3 |
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Publish the current object revision |
|
365
|
|
|
* |
|
366
|
|
|
* @return ObjectInterface Object |
|
367
|
|
|
*/ |
|
368
|
2 |
|
public function publish() |
|
369
|
|
|
{ |
|
370
|
|
|
// If this is an unpublished draft |
|
371
|
2 |
|
if ($this->isDraft() & !$this->hasBeenPublished()) { |
|
372
|
2 |
|
$this->setPublishedState(); |
|
373
|
2 |
|
$this->latestRevision = $this->latestRevision->setDraft(false); |
|
374
|
2 |
|
$this->updateLocator(); |
|
375
|
2 |
|
} |
|
376
|
|
|
|
|
377
|
2 |
|
return $this; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* Delete the object and all its revisions |
|
382
|
|
|
* |
|
383
|
|
|
* @return ObjectInterface Object |
|
384
|
|
|
*/ |
|
385
|
3 |
|
public function delete() |
|
386
|
|
|
{ |
|
387
|
|
|
// If this object is not already deleted |
|
388
|
3 |
|
if (!$this->isDeleted() && !$this->hasBeenDeleted()) { |
|
389
|
3 |
|
$this->setDeletedState(); |
|
390
|
3 |
|
$this->updateLocator(); |
|
391
|
3 |
|
} |
|
392
|
|
|
|
|
393
|
3 |
|
return $this; |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* Undelete the object and all its revisions |
|
398
|
|
|
* |
|
399
|
|
|
* @return ObjectInterface Object |
|
400
|
|
|
*/ |
|
401
|
2 |
|
public function undelete() |
|
402
|
|
|
{ |
|
403
|
|
|
// If this object is already deleted |
|
404
|
2 |
|
if ($this->isDeleted() && !$this->hasBeenUndeleted()) { |
|
405
|
2 |
|
$this->setUndeletedState(); |
|
406
|
2 |
|
$this->updateLocator(); |
|
407
|
2 |
|
} |
|
408
|
|
|
|
|
409
|
2 |
|
return $this; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
/** |
|
413
|
|
|
* Convert this object revision into a draft |
|
414
|
|
|
*/ |
|
415
|
5 |
|
protected function convertToDraft() |
|
416
|
|
|
{ |
|
417
|
|
|
// Assume the latest revision as draft revision |
|
418
|
5 |
|
$draftRevision = $this->latestRevision; |
|
419
|
|
|
|
|
420
|
|
|
// If it equals the current revision: Spawn a draft |
|
421
|
5 |
|
if ($draftRevision->equals($this->getCurrentRevision())) { |
|
422
|
5 |
|
$draftRevision = $this->latestRevision = $draftRevision->increment()->setDraft(true); |
|
423
|
5 |
|
} |
|
424
|
|
|
|
|
425
|
|
|
// Set the system properties to draft mode |
|
426
|
5 |
|
$this->setSystemProperties($this->systemProperties->createDraft($draftRevision), true); |
|
427
|
|
|
|
|
428
|
|
|
// Update the object locator |
|
429
|
5 |
|
$this->updateLocator(); |
|
430
|
5 |
|
} |
|
431
|
|
|
} |
|
432
|
|
|
|