1
|
|
|
<?php |
2
|
|
|
namespace Dkd\PhpCmis\DataObjects; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of php-cmis-client. |
6
|
|
|
* |
7
|
|
|
* (c) Sascha Egerer <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use Dkd\PhpCmis\CmisObject\CmisObjectInterface; |
14
|
|
|
use Dkd\PhpCmis\Constants; |
15
|
|
|
use Dkd\PhpCmis\Data\AceInterface; |
16
|
|
|
use Dkd\PhpCmis\Data\DocumentInterface; |
17
|
|
|
use Dkd\PhpCmis\Data\FailedToDeleteDataInterface; |
18
|
|
|
use Dkd\PhpCmis\Data\FolderInterface; |
19
|
|
|
use Dkd\PhpCmis\Data\ItemInterface; |
20
|
|
|
use Dkd\PhpCmis\Data\ObjectIdInterface; |
21
|
|
|
use Dkd\PhpCmis\Data\ObjectInFolderContainerInterface; |
22
|
|
|
use Dkd\PhpCmis\Data\ObjectTypeInterface; |
23
|
|
|
use Dkd\PhpCmis\Data\PolicyInterface; |
24
|
|
|
use Dkd\PhpCmis\Enum\IncludeRelationships; |
25
|
|
|
use Dkd\PhpCmis\Enum\UnfileObject; |
26
|
|
|
use Dkd\PhpCmis\Enum\VersioningState; |
27
|
|
|
use Dkd\PhpCmis\Exception\CmisRuntimeException; |
28
|
|
|
use Dkd\PhpCmis\OperationContextInterface; |
29
|
|
|
use Dkd\PhpCmis\PropertyIds; |
30
|
|
|
use Dkd\PhpCmis\TreeInterface; |
31
|
|
|
use GuzzleHttp\Stream\StreamInterface; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Cmis folder implementation |
35
|
|
|
*/ |
36
|
|
|
class Folder extends AbstractFileableCmisObject implements FolderInterface |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Creates a new document in this folder. |
40
|
|
|
* |
41
|
|
|
* @param array $properties The property values that MUST be applied to the object. The array key is the property |
42
|
|
|
* name the value is the property value. |
43
|
|
|
* @param StreamInterface $contentStream |
44
|
|
|
* @param VersioningState $versioningState An enumeration specifying what the versioning state of the newly-created |
45
|
|
|
* object MUST be. Valid values are: |
46
|
|
|
* <code>none</code> |
47
|
|
|
* (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
48
|
|
|
* document. |
49
|
|
|
* <code>checkedout</code> |
50
|
|
|
* The document MUST be created in the checked-out state. The checked-out document MAY be |
51
|
|
|
* visible to other users. |
52
|
|
|
* <code>major</code> |
53
|
|
|
* (default, if the object-type is versionable) The document MUST be created as a major version. |
54
|
|
|
* <code>minor</code> |
55
|
|
|
* The document MUST be created as a minor version. |
56
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document |
57
|
|
|
* object. |
58
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either |
59
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
60
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object, |
61
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
62
|
|
|
* @param OperationContextInterface|null $context |
63
|
|
|
* @return DocumentInterface|null the new folder object or <code>null</code> if the parameter <code>context</code> |
64
|
|
|
* was set to <code>null</code> |
65
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a document |
66
|
|
|
*/ |
67
|
|
View Code Duplication |
public function createDocument( |
|
|
|
|
68
|
|
|
array $properties, |
69
|
|
|
StreamInterface $contentStream, |
70
|
|
|
VersioningState $versioningState, |
71
|
|
|
array $policies = [], |
72
|
|
|
array $addAces = [], |
73
|
|
|
array $removeAces = [], |
74
|
|
|
OperationContextInterface $context = null |
75
|
|
|
) { |
76
|
|
|
$newObjectId = $this->getSession()->createDocument( |
77
|
|
|
$properties, |
78
|
|
|
$this, |
79
|
|
|
$contentStream, |
80
|
|
|
$versioningState, |
81
|
|
|
$policies, |
82
|
|
|
$addAces, |
83
|
|
|
$removeAces |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
$document = $this->getNewlyCreatedObject($newObjectId, $context); |
87
|
|
|
|
88
|
|
|
if ($document === null) { |
89
|
|
|
return null; |
90
|
|
|
} elseif (!$document instanceof DocumentInterface) { |
91
|
|
|
throw new CmisRuntimeException('Newly created object is not a document! New id: ' . $document->getId()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return $document; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Creates a new document from a source document in this folder. |
99
|
|
|
* |
100
|
|
|
* @param ObjectIdInterface $source The ID of the source document. |
101
|
|
|
* @param array $properties The property values that MUST be applied to the object. The array key is the property |
102
|
|
|
* name the value is the property value. |
103
|
|
|
* @param VersioningState $versioningState An enumeration specifying what the versioning state of the newly-created |
104
|
|
|
* object MUST be. Valid values are: |
105
|
|
|
* <code>none</code> |
106
|
|
|
* (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
107
|
|
|
* document. |
108
|
|
|
* <code>checkedout</code> |
109
|
|
|
* The document MUST be created in the checked-out state. The checked-out document MAY be |
110
|
|
|
* visible to other users. |
111
|
|
|
* <code>major</code> |
112
|
|
|
* (default, if the object-type is versionable) The document MUST be created as a major version. |
113
|
|
|
* <code>minor</code> |
114
|
|
|
* The document MUST be created as a minor version. |
115
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document |
116
|
|
|
* object. |
117
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either |
118
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
119
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object, |
120
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
121
|
|
|
* @param OperationContextInterface|null $context |
122
|
|
|
* @return DocumentInterface|null the new folder object or <code>null</code> if the parameter <code>context</code> |
123
|
|
|
* was set to <code>null</code> |
124
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a document |
125
|
|
|
*/ |
126
|
|
View Code Duplication |
public function createDocumentFromSource( |
|
|
|
|
127
|
|
|
ObjectIdInterface $source, |
128
|
|
|
array $properties, |
129
|
|
|
VersioningState $versioningState, |
130
|
|
|
array $policies = [], |
131
|
|
|
array $addAces = [], |
132
|
|
|
array $removeAces = [], |
133
|
|
|
OperationContextInterface $context = null |
134
|
|
|
) { |
135
|
|
|
$newObjectId = $this->getSession()->createDocumentFromSource( |
136
|
|
|
$source, |
137
|
|
|
$properties, |
138
|
|
|
$this, |
139
|
|
|
$versioningState, |
140
|
|
|
$policies, |
141
|
|
|
$addAces, |
142
|
|
|
$removeAces |
143
|
|
|
); |
144
|
|
|
|
145
|
|
|
$document = $this->getNewlyCreatedObject($newObjectId, $context); |
146
|
|
|
|
147
|
|
|
if ($document === null) { |
148
|
|
|
return null; |
149
|
|
|
} elseif (!$document instanceof DocumentInterface) { |
150
|
|
|
throw new CmisRuntimeException('Newly created object is not a document! New id: ' . $document->getId()); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
return $document; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Creates a new subfolder in this folder. |
158
|
|
|
* |
159
|
|
|
* @param array $properties The property values that MUST be applied to the newly-created item object. |
160
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created folder object. |
161
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created folder object, either |
162
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
163
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created folder object, |
164
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
165
|
|
|
* @param OperationContextInterface|null $context |
166
|
|
|
* @return FolderInterface|null the new folder object or <code>null</code> if the parameter <code>context</code> |
167
|
|
|
* was set to <code>null</code> |
168
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a folder |
169
|
|
|
*/ |
170
|
|
View Code Duplication |
public function createFolder( |
|
|
|
|
171
|
|
|
array $properties, |
172
|
|
|
array $policies = [], |
173
|
|
|
array $addAces = [], |
174
|
|
|
array $removeAces = [], |
175
|
|
|
OperationContextInterface $context = null |
176
|
|
|
) { |
177
|
|
|
$newObjectId = $this->getSession()->createFolder($properties, $this, $policies, $addAces, $removeAces); |
178
|
|
|
|
179
|
|
|
$folder = $this->getNewlyCreatedObject($newObjectId, $context); |
180
|
|
|
|
181
|
|
|
if ($folder === null) { |
182
|
|
|
return null; |
183
|
|
|
} elseif (!$folder instanceof FolderInterface) { |
184
|
|
|
throw new CmisRuntimeException('Newly created object is not a folder! New id: ' . $folder->getId()); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
return $folder; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Creates a new item in this folder. |
192
|
|
|
* |
193
|
|
|
* @param array $properties The property values that MUST be applied to the newly-created item object. |
194
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created item object. |
195
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created item object, either using |
196
|
|
|
* the ACL from folderId if specified, or being applied if no folderId is specified. |
197
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created item object, either |
198
|
|
|
* using the ACL from folderId if specified, or being ignored if no folderId is specified. |
199
|
|
|
* @param OperationContextInterface|null $context |
200
|
|
|
* @return ItemInterface|null the new item object |
201
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a item |
202
|
|
|
*/ |
203
|
|
View Code Duplication |
public function createItem( |
|
|
|
|
204
|
|
|
array $properties, |
205
|
|
|
array $policies = [], |
206
|
|
|
array $addAces = [], |
207
|
|
|
array $removeAces = [], |
208
|
|
|
OperationContextInterface $context = null |
209
|
|
|
) { |
210
|
|
|
$newObjectId = $this->getSession()->createItem($properties, $this, $policies, $addAces, $removeAces); |
211
|
|
|
|
212
|
|
|
$item = $this->getNewlyCreatedObject($newObjectId, $context); |
213
|
|
|
|
214
|
|
|
if ($item === null) { |
215
|
|
|
return null; |
216
|
|
|
} elseif (!$item instanceof ItemInterface) { |
217
|
|
|
throw new CmisRuntimeException('Newly created object is not a item! New id: ' . $item->getId()); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
return $item; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Creates a new policy in this folder. |
225
|
|
|
* |
226
|
|
|
* @param array $properties The property values that MUST be applied to the newly-created policy object. |
227
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created policy object. |
228
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created policy object, either |
229
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
230
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created policy object, |
231
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
232
|
|
|
* @param OperationContextInterface|null $context |
233
|
|
|
* @return PolicyInterface|null the new policy object |
234
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a policy |
235
|
|
|
*/ |
236
|
|
View Code Duplication |
public function createPolicy( |
|
|
|
|
237
|
|
|
array $properties, |
238
|
|
|
array $policies = [], |
239
|
|
|
array $addAces = [], |
240
|
|
|
array $removeAces = [], |
241
|
|
|
OperationContextInterface $context = null |
242
|
|
|
) { |
243
|
|
|
$newObjectId = $this->getSession()->createPolicy($properties, $this, $policies, $addAces, $removeAces); |
244
|
|
|
|
245
|
|
|
$policy = $this->getNewlyCreatedObject($newObjectId, $context); |
246
|
|
|
|
247
|
|
|
if ($policy === null) { |
248
|
|
|
return null; |
249
|
|
|
} elseif (!$policy instanceof PolicyInterface) { |
250
|
|
|
throw new CmisRuntimeException('Newly created object is not a policy! New id: ' . $policy->getId()); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
return $policy; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Deletes this folder and all subfolders. |
258
|
|
|
* |
259
|
|
|
* @param boolean $allVersions If <code>true</code>, then delete all versions of all documents. If |
260
|
|
|
* <code>false</code>, delete only the document versions referenced in the tree. The repository MUST ignore the |
261
|
|
|
* value of this parameter when this service is invoked on any non-document objects or non-versionable document |
262
|
|
|
* objects. |
263
|
|
|
* @param UnfileObject $unfile An enumeration specifying how the repository MUST process file-able child- or |
264
|
|
|
* descendant-objects. |
265
|
|
|
* @param boolean $continueOnFailure If <code>true</code>, then the repository SHOULD continue attempting to |
266
|
|
|
* perform this operation even if deletion of a child- or descendant-object in the specified folder cannot be |
267
|
|
|
* deleted. If <code>false</code>, then the repository SHOULD abort this method when it fails to |
268
|
|
|
* delete a single child object or descendant object. |
269
|
|
|
* @return FailedToDeleteDataInterface A list of identifiers of objects in the folder tree that were not deleted. |
270
|
|
|
*/ |
271
|
|
|
public function deleteTree($allVersions, UnfileObject $unfile, $continueOnFailure = true) |
272
|
|
|
{ |
273
|
|
|
$failed = $this->getBinding()->getObjectService()->deleteTree( |
274
|
|
|
$this->getRepositoryId(), |
275
|
|
|
$this->getId(), |
276
|
|
|
$allVersions, |
277
|
|
|
$unfile, |
278
|
|
|
$continueOnFailure |
279
|
|
|
); |
280
|
|
|
|
281
|
|
|
if (count($failed->getIds()) === 0) { |
282
|
|
|
$this->getSession()->removeObjectFromCache($this); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
return $failed; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Returns all checked out documents in this folder using the given OperationContext. |
290
|
|
|
* |
291
|
|
|
* @param OperationContextInterface|null $context |
292
|
|
|
* @return DocumentInterface[] A list of checked out documents. |
293
|
|
|
*/ |
294
|
|
|
public function getCheckedOutDocs(OperationContextInterface $context = null) |
295
|
|
|
{ |
296
|
|
|
$context = $this->ensureContext($context); |
297
|
|
|
$checkedOutDocs = $this->getBinding()->getNavigationService()->getCheckedOutDocs( |
298
|
|
|
$this->getRepositoryId(), |
299
|
|
|
$this->getId(), |
300
|
|
|
$context->getQueryFilterString(), |
301
|
|
|
$context->getOrderBy(), |
302
|
|
|
$context->isIncludeAllowableActions(), |
303
|
|
|
$context->getIncludeRelationships(), |
304
|
|
|
$context->getRenditionFilterString() |
305
|
|
|
); |
306
|
|
|
|
307
|
|
|
$result = []; |
308
|
|
|
$objectFactory = $this->getObjectFactory(); |
309
|
|
|
foreach ($checkedOutDocs->getObjects() as $objectData) { |
310
|
|
|
$document = $objectFactory->convertObject($objectData, $context); |
311
|
|
|
if (!($document instanceof DocumentInterface)) { |
312
|
|
|
// should not happen but could happen if the repository is not implemented correctly ... |
313
|
|
|
continue; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
$result[] = $document; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
return $result; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Returns the children of this folder using the given OperationContext. |
324
|
|
|
* |
325
|
|
|
* @param OperationContextInterface|null $context |
326
|
|
|
* @return CmisObjectInterface[] A list of the child objects for the specified folder. |
327
|
|
|
*/ |
328
|
|
|
public function getChildren(OperationContextInterface $context = null) |
329
|
|
|
{ |
330
|
|
|
$context = $this->ensureContext($context); |
331
|
|
|
$children = $this->getBinding()->getNavigationService()->getChildren( |
332
|
|
|
$this->getRepositoryId(), |
333
|
|
|
$this->getId(), |
334
|
|
|
$context->getQueryFilterString(), |
335
|
|
|
$context->getOrderBy(), |
336
|
|
|
$context->isIncludeAllowableActions(), |
337
|
|
|
$context->getIncludeRelationships(), |
338
|
|
|
$context->getRenditionFilterString(), |
339
|
|
|
$context->isIncludePathSegments() |
340
|
|
|
); |
341
|
|
|
|
342
|
|
|
$result = []; |
343
|
|
|
$objectFactory = $this->getObjectFactory(); |
344
|
|
|
foreach ($children->getObjects() as $objectData) { |
345
|
|
|
if ($objectData->getObject() !== null) { |
346
|
|
|
$result[] = $objectFactory->convertObject($objectData->getObject(), $context); |
347
|
|
|
} |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
return $result; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Gets the folder descendants starting with this folder. |
355
|
|
|
* |
356
|
|
|
* @param integer $depth |
357
|
|
|
* @param OperationContextInterface|null $context |
358
|
|
|
* @return TreeInterface A tree that contains FileableCmisObject objects |
359
|
|
|
* @see FileableCmisObject FileableCmisObject contained in returned TreeInterface |
360
|
|
|
*/ |
361
|
|
View Code Duplication |
public function getDescendants($depth, OperationContextInterface $context = null) |
|
|
|
|
362
|
|
|
{ |
363
|
|
|
$context = $this->ensureContext($context); |
364
|
|
|
$containerList = $this->getBinding()->getNavigationService()->getDescendants( |
365
|
|
|
$this->getRepositoryId(), |
366
|
|
|
$this->getId(), |
367
|
|
|
(int) $depth, |
368
|
|
|
$context->getQueryFilterString(), |
369
|
|
|
$context->isIncludeAllowableActions(), |
370
|
|
|
$context->getIncludeRelationships(), |
371
|
|
|
$context->getRenditionFilterString(), |
372
|
|
|
$context->isIncludePathSegments() |
373
|
|
|
); |
374
|
|
|
|
375
|
|
|
return $this->convertBindingContainer($containerList, $context); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* Gets the parent folder object. |
380
|
|
|
* |
381
|
|
|
* @return FolderInterface|null the parent folder object or <code>null</code> if the folder is the root folder. |
382
|
|
|
*/ |
383
|
|
|
public function getFolderParent() |
384
|
|
|
{ |
385
|
|
|
if ($this->isRootFolder()) { |
386
|
|
|
return null; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
$parents = $this->getParents($this->getSession()->getDefaultContext()); |
390
|
|
|
|
391
|
|
|
// return the first element of the array |
392
|
|
|
$parent = reset($parents); |
393
|
|
|
|
394
|
|
|
if (!$parent instanceof FolderInterface) { |
395
|
|
|
return null; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
return $parent; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* Gets the folder tree starting with this folder using the given OperationContext. |
403
|
|
|
* |
404
|
|
|
* @param integer $depth The number of levels of depth in the folder hierarchy from which to return results. |
405
|
|
|
* Valid values are: |
406
|
|
|
* 1 |
407
|
|
|
* Return only objects that are children of the folder. See also getChildren. |
408
|
|
|
* <Integer value greater than 1> |
409
|
|
|
* Return only objects that are children of the folder and descendants up to <value> levels deep. |
410
|
|
|
* -1 |
411
|
|
|
* Return ALL descendant objects at all depth levels in the CMIS hierarchy. |
412
|
|
|
* The default value is repository specific and SHOULD be at least 2 or -1. |
413
|
|
|
* @param OperationContextInterface|null $context |
414
|
|
|
* @return TreeInterface A tree that contains FileableCmisObject objects |
415
|
|
|
* @see FileableCmisObject FileableCmisObject contained in returned TreeInterface |
416
|
|
|
*/ |
417
|
|
View Code Duplication |
public function getFolderTree($depth, OperationContextInterface $context = null) |
|
|
|
|
418
|
|
|
{ |
419
|
|
|
$context = $this->ensureContext($context); |
420
|
|
|
$containerList = $this->getBinding()->getNavigationService()->getFolderTree( |
421
|
|
|
$this->getRepositoryId(), |
422
|
|
|
$this->getId(), |
423
|
|
|
(int) $depth, |
424
|
|
|
$context->getQueryFilterString(), |
425
|
|
|
$context->isIncludeAllowableActions(), |
426
|
|
|
$context->getIncludeRelationships(), |
427
|
|
|
$context->getRenditionFilterString(), |
428
|
|
|
$context->isIncludePathSegments() |
429
|
|
|
); |
430
|
|
|
|
431
|
|
|
return $this->convertBindingContainer($containerList, $context); |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
/** |
435
|
|
|
* Returns the path of the folder. |
436
|
|
|
* |
437
|
|
|
* @return string the absolute folder path |
438
|
|
|
*/ |
439
|
|
|
public function getPath() |
440
|
|
|
{ |
441
|
|
|
$path = $this->getPropertyValue(PropertyIds::PATH); |
442
|
|
|
|
443
|
|
|
// if the path property isn't set, get it |
444
|
|
|
if ($path === null) { |
445
|
|
|
$objectData = $this->getBinding()->getObjectService()->getObject( |
446
|
|
|
$this->getRepositoryId(), |
447
|
|
|
$this->getId(), |
448
|
|
|
$this->getPropertyQueryName(PropertyIds::PATH), |
449
|
|
|
false, |
450
|
|
|
IncludeRelationships::cast(IncludeRelationships::NONE), |
451
|
|
|
Constants::RENDITION_NONE, |
452
|
|
|
false, |
453
|
|
|
false |
454
|
|
|
); |
455
|
|
|
|
456
|
|
|
if ($objectData !== null |
457
|
|
|
&& $objectData->getProperties() !== null |
458
|
|
|
&& $objectData->getProperties()->getProperties() !== null |
459
|
|
|
) { |
460
|
|
|
$objectProperties = $objectData->getProperties()->getProperties(); |
461
|
|
|
if (isset($objectProperties[PropertyIds::PATH]) |
462
|
|
|
&& $objectProperties[PropertyIds::PATH] instanceof PropertyString |
463
|
|
|
) { |
464
|
|
|
$path = $objectProperties[PropertyIds::PATH]->getFirstValue(); |
465
|
|
|
} |
466
|
|
|
} |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
// we still don't know the path ... it's not a CMIS compliant repository |
470
|
|
|
if ($path === null) { |
471
|
|
|
throw new CmisRuntimeException('Repository didn\'t return ' . PropertyIds::PATH . '!'); |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
return $path; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Returns if the folder is the root folder. |
479
|
|
|
* |
480
|
|
|
* @return boolean <code>true</code> if the folder is the root folder, <code>false</code> otherwise |
481
|
|
|
*/ |
482
|
|
|
public function isRootFolder() |
483
|
|
|
{ |
484
|
|
|
return $this->getSession()->getRepositoryInfo()->getRootFolderId() === $this->getId(); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Returns the list of the allowed object types in this folder (CMIS property cmis:allowedChildObjectTypeIds). |
489
|
|
|
* If the list is empty or <code>null</code> all object types are allowed. |
490
|
|
|
* |
491
|
|
|
* @return ObjectTypeInterface[] the property value or <code>null</code> if the property hasn't been requested, |
492
|
|
|
* hasn't been provided by the repository, or the property value isn't set |
493
|
|
|
*/ |
494
|
|
|
public function getAllowedChildObjectTypes() |
495
|
|
|
{ |
496
|
|
|
$result = []; |
497
|
|
|
|
498
|
|
|
$objectTypeIds = $this->getPropertyValue(PropertyIds::ALLOWED_CHILD_OBJECT_TYPE_IDS); |
499
|
|
|
if ($objectTypeIds === null) { |
500
|
|
|
return $result; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
foreach ($objectTypeIds as $objectTypeId) { |
504
|
|
|
$result[] = $this->getSession()->getTypeDefinition($objectTypeId); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
return $result; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
/** |
511
|
|
|
* Returns the parent id or <code>null</code> if the folder is the root folder (CMIS property cmis:parentId). |
512
|
|
|
* |
513
|
|
|
* @return string|null the property value or <code>null</code> if the property hasn't been requested, hasn't |
514
|
|
|
* been provided by the repository, or the folder is the root folder |
515
|
|
|
*/ |
516
|
|
|
public function getParentId() |
517
|
|
|
{ |
518
|
|
|
return $this->getPropertyValue(PropertyIds::PARENT_ID); |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Converts a binding container into an API container. |
524
|
|
|
* |
525
|
|
|
* @param ObjectInFolderContainerInterface[] $bindingContainerList |
526
|
|
|
* @param OperationContextInterface $context |
527
|
|
|
* @return TreeInterface[] |
528
|
|
|
*/ |
529
|
|
|
private function convertBindingContainer(array $bindingContainerList, OperationContextInterface $context) |
|
|
|
|
530
|
|
|
{ |
531
|
|
|
// TODO implement when Tree and ObjectInFolderContainer is implemented |
532
|
|
|
throw new \Exception('Not yet implemented!'); |
533
|
|
|
} |
534
|
|
|
} |
535
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.