|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File contains: eZ\Publish\Core\Repository\Tests\Service\Integration\TrashBase class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\Repository\Tests\Service\Integration; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Repository\Tests\Service\Integration\Base as BaseServiceTest; |
|
12
|
|
|
use eZ\Publish\Core\Repository\Values\Content\TrashItem; |
|
13
|
|
|
use eZ\Publish\Core\Repository\Values\Content\Location; |
|
14
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query; |
|
15
|
|
|
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct; |
|
16
|
|
|
use eZ\Publish\API\Repository\Exceptions\PropertyNotFoundException as PropertyNotFound; |
|
17
|
|
|
use eZ\Publish\API\Repository\Exceptions\PropertyReadOnlyException; |
|
18
|
|
|
use eZ\Publish\API\Repository\Exceptions\NotFoundException; |
|
19
|
|
|
use eZ\Publish\API\Repository\Tests\BaseTest as APIBaseTest; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Test case for Trash Service. |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class TrashBase extends BaseServiceTest |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Test a new class and default values on properties. |
|
28
|
|
|
* |
|
29
|
|
|
* @covers \eZ\Publish\API\Repository\Values\Content\TrashItem::__construct |
|
30
|
|
|
*/ |
|
31
|
|
View Code Duplication |
public function testNewClass() |
|
32
|
|
|
{ |
|
33
|
|
|
$trashItem = new TrashItem(); |
|
34
|
|
|
|
|
35
|
|
|
$this->assertPropertiesCorrect( |
|
36
|
|
|
array( |
|
37
|
|
|
'id' => null, |
|
38
|
|
|
'priority' => null, |
|
39
|
|
|
'hidden' => null, |
|
40
|
|
|
'invisible' => null, |
|
41
|
|
|
'remoteId' => null, |
|
42
|
|
|
'parentLocationId' => null, |
|
43
|
|
|
'pathString' => null, |
|
44
|
|
|
'depth' => null, |
|
45
|
|
|
'sortField' => null, |
|
46
|
|
|
'sortOrder' => null, |
|
47
|
|
|
), |
|
48
|
|
|
$trashItem |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test retrieving missing property. |
|
54
|
|
|
* |
|
55
|
|
|
* @covers \eZ\Publish\API\Repository\Values\Content\TrashItem::__get |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testMissingProperty() |
|
58
|
|
|
{ |
|
59
|
|
|
try { |
|
60
|
|
|
$trashItem = new TrashItem(); |
|
61
|
|
|
$value = $trashItem->notDefined; |
|
|
|
|
|
|
62
|
|
|
self::fail('Succeeded getting non existing property'); |
|
63
|
|
|
} catch (PropertyNotFound $e) { |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Test setting read only property. |
|
69
|
|
|
* |
|
70
|
|
|
* @covers \eZ\Publish\API\Repository\Values\Content\TrashItem::__set |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testReadOnlyProperty() |
|
73
|
|
|
{ |
|
74
|
|
|
try { |
|
75
|
|
|
$trashItem = new TrashItem(); |
|
76
|
|
|
$trashItem->id = 42; |
|
|
|
|
|
|
77
|
|
|
self::fail('Succeeded setting read only property'); |
|
78
|
|
|
} catch (PropertyReadOnlyException $e) { |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Test if property exists. |
|
84
|
|
|
* |
|
85
|
|
|
* @covers \eZ\Publish\API\Repository\Values\Content\TrashItem::__isset |
|
86
|
|
|
*/ |
|
87
|
|
|
public function testIsPropertySet() |
|
88
|
|
|
{ |
|
89
|
|
|
$trashItem = new TrashItem(); |
|
90
|
|
|
$value = isset($trashItem->notDefined); |
|
91
|
|
|
self::assertEquals(false, $value); |
|
92
|
|
|
|
|
93
|
|
|
$value = isset($trashItem->id); |
|
|
|
|
|
|
94
|
|
|
self::assertEquals(true, $value); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Test unsetting a property. |
|
99
|
|
|
* |
|
100
|
|
|
* @covers \eZ\Publish\API\Repository\Values\Content\TrashItem::__unset |
|
101
|
|
|
*/ |
|
102
|
|
|
public function testUnsetProperty() |
|
103
|
|
|
{ |
|
104
|
|
|
$trashItem = new TrashItem(array('id' => 2)); |
|
105
|
|
|
try { |
|
106
|
|
|
unset($trashItem->id); |
|
107
|
|
|
self::fail('Unsetting read-only property succeeded'); |
|
108
|
|
|
} catch (PropertyReadOnlyException $e) { |
|
|
|
|
|
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Test loading a trash item. |
|
114
|
|
|
* |
|
115
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::loadTrashItem |
|
116
|
|
|
*/ |
|
117
|
|
View Code Duplication |
public function testLoadTrashItem() |
|
118
|
|
|
{ |
|
119
|
|
|
$locationService = $this->repository->getLocationService(); |
|
120
|
|
|
$trashService = $this->repository->getTrashService(); |
|
121
|
|
|
|
|
122
|
|
|
$trashItem = $location = $trashService->trash($locationService->loadLocation(44)); |
|
123
|
|
|
$loadedTrashItem = $trashService->loadTrashItem($location->id); |
|
124
|
|
|
|
|
125
|
|
|
self::assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\TrashItem', $trashItem); |
|
126
|
|
|
|
|
127
|
|
|
self::assertSameClassPropertiesCorrect( |
|
128
|
|
|
array( |
|
129
|
|
|
'id', |
|
130
|
|
|
'priority', |
|
131
|
|
|
'hidden', |
|
132
|
|
|
'invisible', |
|
133
|
|
|
'remoteId', |
|
134
|
|
|
'parentLocationId', |
|
135
|
|
|
'pathString', |
|
136
|
|
|
'depth', |
|
137
|
|
|
'sortField', |
|
138
|
|
|
'sortOrder', |
|
139
|
|
|
), |
|
140
|
|
|
$trashItem, |
|
141
|
|
|
$loadedTrashItem |
|
142
|
|
|
); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Test loading a trash item throwing NotFoundException. |
|
147
|
|
|
* |
|
148
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
149
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::loadTrashItem |
|
150
|
|
|
*/ |
|
151
|
|
|
public function testLoadTrashItemThrowsNotFoundException() |
|
152
|
|
|
{ |
|
153
|
|
|
$trashService = $this->repository->getTrashService(); |
|
154
|
|
|
$trashService->loadTrashItem(44); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Test sending a location to trash. |
|
159
|
|
|
* |
|
160
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::trash |
|
161
|
|
|
*/ |
|
162
|
|
View Code Duplication |
public function testTrash() |
|
163
|
|
|
{ |
|
164
|
|
|
$locationService = $this->repository->getLocationService(); |
|
165
|
|
|
$trashService = $this->repository->getTrashService(); |
|
166
|
|
|
|
|
167
|
|
|
$location = $locationService->loadLocation(44); |
|
168
|
|
|
$trashItem = $trashService->trash($location); |
|
169
|
|
|
|
|
170
|
|
|
self::assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\TrashItem', $trashItem); |
|
171
|
|
|
|
|
172
|
|
|
self::assertSameClassPropertiesCorrect( |
|
173
|
|
|
array( |
|
174
|
|
|
'id', |
|
175
|
|
|
'priority', |
|
176
|
|
|
'hidden', |
|
177
|
|
|
'invisible', |
|
178
|
|
|
'remoteId', |
|
179
|
|
|
'parentLocationId', |
|
180
|
|
|
'pathString', |
|
181
|
|
|
'depth', |
|
182
|
|
|
'sortField', |
|
183
|
|
|
'sortOrder', |
|
184
|
|
|
), |
|
185
|
|
|
$location, |
|
186
|
|
|
$trashItem |
|
187
|
|
|
); |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Test sending a location to trash. |
|
192
|
|
|
* |
|
193
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::trash |
|
194
|
|
|
*/ |
|
195
|
|
|
public function testTrashUpdatesMainLocation() |
|
196
|
|
|
{ |
|
197
|
|
|
$contentService = $this->repository->getContentService(); |
|
198
|
|
|
$locationService = $this->repository->getLocationService(); |
|
199
|
|
|
$trashService = $this->repository->getTrashService(); |
|
200
|
|
|
|
|
201
|
|
|
$contentInfo = $contentService->loadContentInfo(42); |
|
202
|
|
|
|
|
203
|
|
|
// Create additional location that will become new main location |
|
204
|
|
|
$location = $locationService->createLocation( |
|
205
|
|
|
$contentInfo, |
|
206
|
|
|
new LocationCreateStruct(array('parentLocationId' => 2)) |
|
207
|
|
|
); |
|
208
|
|
|
|
|
209
|
|
|
$trashService->trash( |
|
210
|
|
|
$locationService->loadLocation($contentInfo->mainLocationId) |
|
211
|
|
|
); |
|
212
|
|
|
|
|
213
|
|
|
self::assertEquals( |
|
214
|
|
|
$location->id, |
|
215
|
|
|
$contentService->loadContentInfo(42)->mainLocationId |
|
216
|
|
|
); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Test sending a location to trash. |
|
221
|
|
|
* |
|
222
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::trash |
|
223
|
|
|
*/ |
|
224
|
|
View Code Duplication |
public function testTrashReturnsNull() |
|
225
|
|
|
{ |
|
226
|
|
|
$contentService = $this->repository->getContentService(); |
|
227
|
|
|
$locationService = $this->repository->getLocationService(); |
|
228
|
|
|
$trashService = $this->repository->getTrashService(); |
|
229
|
|
|
|
|
230
|
|
|
// Create additional location to trash |
|
231
|
|
|
$location = $locationService->createLocation( |
|
232
|
|
|
$contentService->loadContentInfo(42), |
|
233
|
|
|
new LocationCreateStruct(array('parentLocationId' => 2)) |
|
234
|
|
|
); |
|
235
|
|
|
|
|
236
|
|
|
$trashItem = $trashService->trash($location); |
|
237
|
|
|
|
|
238
|
|
|
self::assertNull($trashItem); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* Test recovering a location from trash to original location. |
|
243
|
|
|
* |
|
244
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::recover |
|
245
|
|
|
*/ |
|
246
|
|
|
public function testRecover() |
|
247
|
|
|
{ |
|
248
|
|
|
$locationService = $this->repository->getLocationService(); |
|
249
|
|
|
$trashService = $this->repository->getTrashService(); |
|
250
|
|
|
|
|
251
|
|
|
$location = $locationService->loadLocation(44); |
|
252
|
|
|
$trashItem = $trashService->trash($location); |
|
253
|
|
|
|
|
254
|
|
|
$recoveredLocation = $trashService->recover($trashItem); |
|
|
|
|
|
|
255
|
|
|
|
|
256
|
|
|
self::assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location', $recoveredLocation); |
|
257
|
|
|
|
|
258
|
|
|
self::assertSameClassPropertiesCorrect( |
|
259
|
|
|
array( |
|
260
|
|
|
'priority', |
|
261
|
|
|
'hidden', |
|
262
|
|
|
'invisible', |
|
263
|
|
|
'remoteId', |
|
264
|
|
|
'parentLocationId', |
|
265
|
|
|
'depth', |
|
266
|
|
|
'sortField', |
|
267
|
|
|
'sortOrder', |
|
268
|
|
|
), |
|
269
|
|
|
$location, |
|
270
|
|
|
$recoveredLocation |
|
271
|
|
|
); |
|
272
|
|
|
|
|
273
|
|
|
$parentLocation = $locationService->loadLocation($location->parentLocationId); |
|
274
|
|
|
$newPathString = $parentLocation->pathString . $recoveredLocation->id . '/'; |
|
275
|
|
|
|
|
276
|
|
|
self::assertEquals($newPathString, $recoveredLocation->pathString); |
|
277
|
|
|
self::assertGreaterThan(0, $recoveredLocation->id); |
|
278
|
|
|
self::assertEquals($recoveredLocation->id, $recoveredLocation->contentInfo->mainLocationId); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* Test recovering a non existing trash item. |
|
283
|
|
|
* |
|
284
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
285
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::recover |
|
286
|
|
|
*/ |
|
287
|
|
View Code Duplication |
public function testRecoverNonExistingTrashItem() |
|
288
|
|
|
{ |
|
289
|
|
|
$trashService = $this->repository->getTrashService(); |
|
290
|
|
|
|
|
291
|
|
|
$trashItem = new TrashItem(array('id' => APIBaseTest::DB_INT_MAX, 'parentLocationId' => APIBaseTest::DB_INT_MAX)); |
|
292
|
|
|
$trashService->recover($trashItem); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* Test recovering a location from trash to different location. |
|
297
|
|
|
* |
|
298
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::recover |
|
299
|
|
|
*/ |
|
300
|
|
|
public function testRecoverToDifferentLocation() |
|
301
|
|
|
{ |
|
302
|
|
|
// @todo: remove creating test locations when field types are fully functional |
|
303
|
|
|
// Create test locations |
|
304
|
|
|
$deleteLocationId = $this->createTestContentLocation(5)->contentInfo->mainLocationId; |
|
305
|
|
|
$recoverLocationId = $this->createTestContentLocation(5)->contentInfo->mainLocationId; |
|
306
|
|
|
|
|
307
|
|
|
/* BEGIN: Use Case */ |
|
308
|
|
|
$locationService = $this->repository->getLocationService(); |
|
309
|
|
|
$trashService = $this->repository->getTrashService(); |
|
310
|
|
|
|
|
311
|
|
|
$location = $locationService->loadLocation($deleteLocationId); |
|
312
|
|
|
$trashItem = $trashService->trash($location); |
|
313
|
|
|
|
|
314
|
|
|
$newParentLocation = $locationService->loadLocation($recoverLocationId); |
|
315
|
|
|
|
|
316
|
|
|
$recoveredLocation = $trashService->recover($trashItem, $newParentLocation); |
|
|
|
|
|
|
317
|
|
|
/* END: Use Case */ |
|
318
|
|
|
|
|
319
|
|
|
self::assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location', $recoveredLocation); |
|
320
|
|
|
|
|
321
|
|
|
self::assertSameClassPropertiesCorrect( |
|
322
|
|
|
array( |
|
323
|
|
|
'priority', |
|
324
|
|
|
'hidden', |
|
325
|
|
|
'invisible', |
|
326
|
|
|
'remoteId', |
|
327
|
|
|
'depth', |
|
328
|
|
|
'sortField', |
|
329
|
|
|
'sortOrder', |
|
330
|
|
|
), |
|
331
|
|
|
$location, |
|
332
|
|
|
$recoveredLocation, |
|
333
|
|
|
array('depth') |
|
334
|
|
|
); |
|
335
|
|
|
|
|
336
|
|
|
$parentLocation = $locationService->loadLocation($recoveredLocation->parentLocationId); |
|
337
|
|
|
$newPathString = $parentLocation->pathString . $recoveredLocation->id . '/'; |
|
338
|
|
|
|
|
339
|
|
|
self::assertEquals($parentLocation->depth + 1, $recoveredLocation->depth); |
|
340
|
|
|
self::assertEquals($newPathString, $recoveredLocation->pathString); |
|
341
|
|
|
self::assertGreaterThan(0, $recoveredLocation->id); |
|
342
|
|
|
self::assertEquals($newParentLocation->id, $recoveredLocation->parentLocationId); |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* Test recovering a location from trash to non existing location. |
|
347
|
|
|
* |
|
348
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
349
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::recover |
|
350
|
|
|
*/ |
|
351
|
|
|
public function testRecoverToNonExistingLocation() |
|
352
|
|
|
{ |
|
353
|
|
|
$locationService = $this->repository->getLocationService(); |
|
354
|
|
|
$trashService = $this->repository->getTrashService(); |
|
355
|
|
|
|
|
356
|
|
|
$location = $locationService->loadLocation(44); |
|
357
|
|
|
$trashItem = $trashService->trash($location); |
|
358
|
|
|
|
|
359
|
|
|
$newParentLocation = new Location( |
|
360
|
|
|
array( |
|
361
|
|
|
'id' => APIBaseTest::DB_INT_MAX, |
|
362
|
|
|
'parentLocationId' => APIBaseTest::DB_INT_MAX, |
|
363
|
|
|
) |
|
364
|
|
|
); |
|
365
|
|
|
$trashService->recover($trashItem, $newParentLocation); |
|
|
|
|
|
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
/** |
|
369
|
|
|
* Test deleting a trash item. |
|
370
|
|
|
* |
|
371
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::deleteTrashItem |
|
372
|
|
|
*/ |
|
373
|
|
View Code Duplication |
public function testDeleteTrashItem() |
|
374
|
|
|
{ |
|
375
|
|
|
$locationService = $this->repository->getLocationService(); |
|
376
|
|
|
$trashService = $this->repository->getTrashService(); |
|
377
|
|
|
|
|
378
|
|
|
$location = $locationService->loadLocation(44); |
|
379
|
|
|
$trashItem = $trashService->trash($location); |
|
380
|
|
|
|
|
381
|
|
|
$trashService->deleteTrashItem($trashItem); |
|
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
try { |
|
384
|
|
|
$trashService->loadTrashItem($trashItem->id); |
|
385
|
|
|
self::fail('Succeeded loading deleted trash item'); |
|
386
|
|
|
} catch (NotFoundException $e) { |
|
387
|
|
|
// Do nothing |
|
388
|
|
|
} |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* Test deleting a non existing trash item. |
|
393
|
|
|
* |
|
394
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
395
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::deleteTrashItem |
|
396
|
|
|
*/ |
|
397
|
|
View Code Duplication |
public function testDeleteNonExistingTrashItem() |
|
398
|
|
|
{ |
|
399
|
|
|
$trashService = $this->repository->getTrashService(); |
|
400
|
|
|
|
|
401
|
|
|
$trashItem = new TrashItem(array('id' => APIBaseTest::DB_INT_MAX)); |
|
402
|
|
|
$trashService->deleteTrashItem($trashItem); |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
/** |
|
406
|
|
|
* Test searching for trash items. |
|
407
|
|
|
* |
|
408
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::findTrashItems |
|
409
|
|
|
* @covers \eZ\Publish\API\Repository\TrashService::emptyTrash |
|
410
|
|
|
*/ |
|
411
|
|
|
public function testFindTrashItemsAndEmptyTrash() |
|
412
|
|
|
{ |
|
413
|
|
|
// @todo: remove creating test location when field types are fully functional |
|
414
|
|
|
$newLocationId = $this->createTestContentLocation(5)->contentInfo->mainLocationId; |
|
415
|
|
|
|
|
416
|
|
|
$locationService = $this->repository->getLocationService(); |
|
417
|
|
|
$trashService = $this->repository->getTrashService(); |
|
418
|
|
|
|
|
419
|
|
|
$searchResult = $trashService->findTrashItems(new Query()); |
|
420
|
|
|
$countBeforeTrashing = $searchResult->count; |
|
421
|
|
|
|
|
422
|
|
|
$location = $locationService->loadLocation($newLocationId); |
|
423
|
|
|
$trashService->trash($location); |
|
424
|
|
|
|
|
425
|
|
|
$searchResult = $trashService->findTrashItems(new Query()); |
|
426
|
|
|
$countAfterTrashing = $searchResult->count; |
|
427
|
|
|
|
|
428
|
|
|
self::assertGreaterThan($countBeforeTrashing, $countAfterTrashing); |
|
429
|
|
|
|
|
430
|
|
|
$trashService->emptyTrash(); |
|
431
|
|
|
$searchResult = $trashService->findTrashItems(new Query()); |
|
432
|
|
|
|
|
433
|
|
|
self::assertEquals(0, $searchResult->count); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* @param int $parentLocationId |
|
438
|
|
|
* |
|
439
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
|
440
|
|
|
*/ |
|
441
|
|
View Code Duplication |
protected function createTestContentLocation($parentLocationId) |
|
442
|
|
|
{ |
|
443
|
|
|
$contentService = $this->repository->getContentService(); |
|
444
|
|
|
$contentTypeService = $this->repository->getContentTypeService(); |
|
445
|
|
|
// User Group content type |
|
446
|
|
|
$contentType = $contentTypeService->loadContentType(3); |
|
447
|
|
|
|
|
448
|
|
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
|
449
|
|
|
$contentCreate->setField('name', 'dummy value'); |
|
450
|
|
|
$contentCreate->sectionId = 1; |
|
451
|
|
|
$contentCreate->ownerId = 14; |
|
452
|
|
|
$contentCreate->remoteId = md5(uniqid(get_class($this), true)); |
|
453
|
|
|
$contentCreate->alwaysAvailable = true; |
|
454
|
|
|
|
|
455
|
|
|
$locationCreates = array( |
|
456
|
|
|
new LocationCreateStruct( |
|
457
|
|
|
array( |
|
458
|
|
|
//priority = 0 |
|
459
|
|
|
//hidden = false |
|
460
|
|
|
'remoteId' => md5(uniqid(get_class($this), true)), |
|
461
|
|
|
//sortField = Location::SORT_FIELD_NAME |
|
462
|
|
|
//sortOrder = Location::SORT_ORDER_ASC |
|
463
|
|
|
'parentLocationId' => $parentLocationId, |
|
464
|
|
|
) |
|
465
|
|
|
), |
|
466
|
|
|
); |
|
467
|
|
|
|
|
468
|
|
|
return $contentService->publishVersion( |
|
469
|
|
|
$contentService->createContent( |
|
470
|
|
|
$contentCreate, |
|
471
|
|
|
$locationCreates |
|
472
|
|
|
)->versionInfo |
|
473
|
|
|
); |
|
474
|
|
|
} |
|
475
|
|
|
} |
|
476
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.