|
1
|
|
|
<?php |
|
2
|
|
|
namespace Dkd\PhpCmis\Bindings\Browser; |
|
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\Constants; |
|
14
|
|
|
use Dkd\PhpCmis\Data\ExtensionDataInterface; |
|
15
|
|
|
use Dkd\PhpCmis\Data\ObjectListInterface; |
|
16
|
|
|
use Dkd\PhpCmis\Enum\RelationshipDirection; |
|
17
|
|
|
use Dkd\PhpCmis\RelationshipServiceInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Relationship Service Browser Binding client. |
|
21
|
|
|
*/ |
|
22
|
|
|
class RelationshipService extends AbstractBrowserBindingService implements RelationshipServiceInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Gets all or a subset of relationships associated with an independent object. |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $repositoryId The identifier for the repository. |
|
28
|
|
|
* @param string $objectId The identifier of the object. |
|
29
|
|
|
* @param boolean $includeSubRelationshipTypes If <code>true</code>, then the repository MUST return all |
|
30
|
|
|
* relationships whose object-types are descendant-types of the object-type specified by the typeId parameter |
|
31
|
|
|
* value as well as relationships of the specified type. |
|
32
|
|
|
* If <code>false</code>, then the repository MUST only return relationships whose object-types |
|
33
|
|
|
* is equivalent to the object-type specified by the typeId parameter value. |
|
34
|
|
|
* If the typeId input is not specified, then this input MUST be ignored. |
|
35
|
|
|
* @param RelationshipDirection|null $relationshipDirection Specifying whether the repository MUST return |
|
36
|
|
|
* relationships where the specified object is the source of the relationship, the target of the relationship, |
|
37
|
|
|
* or both. (default is source) |
|
38
|
|
|
* @param string|null $typeId If specified, then the repository MUST return only relationships whose object-type is |
|
39
|
|
|
* of the type specified. See also parameter includeSubRelationshipTypes. |
|
40
|
|
|
* If not specified, then the repository MUST return relationship objects of all types. |
|
41
|
|
|
* @param string|null $filter a comma-separated list of query names that defines which properties |
|
42
|
|
|
* must be returned by the repository (default is repository specific) |
|
43
|
|
|
* @param boolean $includeAllowableActions Whether or not to include in response, the list of allowable actions |
|
44
|
|
|
* @param integer|null $maxItems the maximum number of items to return in a response |
|
45
|
|
|
* (default is repository specific) |
|
46
|
|
|
* @param integer $skipCount number of potential results that the repository MUST skip/page over before |
|
47
|
|
|
* returning any results (default is 0) |
|
48
|
|
|
* @param ExtensionDataInterface|null $extension |
|
49
|
|
|
* @return ObjectListInterface |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getObjectRelationships( |
|
52
|
|
|
$repositoryId, |
|
53
|
|
|
$objectId, |
|
54
|
|
|
$includeSubRelationshipTypes = false, |
|
55
|
|
|
RelationshipDirection $relationshipDirection = null, |
|
56
|
|
|
$typeId = null, |
|
57
|
|
|
$filter = null, |
|
58
|
|
|
$includeAllowableActions = false, |
|
59
|
|
|
$maxItems = null, |
|
60
|
|
|
$skipCount = 0, |
|
61
|
|
|
ExtensionDataInterface $extension = null |
|
62
|
|
|
) { |
|
63
|
|
|
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_RELATIONSHIPS); |
|
64
|
|
|
$query = $url->getQuery(); |
|
65
|
|
|
|
|
66
|
|
|
if ($relationshipDirection === null) { |
|
67
|
|
|
$relationshipDirection = RelationshipDirection::cast(RelationshipDirection::SOURCE); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
$query->modify( |
|
71
|
|
|
[ |
|
72
|
|
|
Constants::PARAM_TYPE_ID => $typeId, |
|
73
|
|
|
Constants::PARAM_RELATIONSHIP_DIRECTION => (string) $relationshipDirection, |
|
74
|
|
|
Constants::PARAM_SUB_RELATIONSHIP_TYPES => $includeSubRelationshipTypes ? 'true' : 'false', |
|
75
|
|
|
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false', |
|
76
|
|
|
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
|
77
|
|
|
Constants::PARAM_SKIP_COUNT => $skipCount, |
|
78
|
|
|
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
|
79
|
|
|
] |
|
80
|
|
|
); |
|
81
|
|
|
|
|
82
|
|
|
if ($filter !== null) { |
|
83
|
|
|
$query->modify([Constants::PARAM_FILTER => $filter]); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if ($maxItems !== null) { |
|
87
|
|
|
$query->modify([Constants::PARAM_MAX_ITEMS => $maxItems]); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$responseData = (array) $this->readJson($url); |
|
91
|
|
|
|
|
92
|
|
|
return $this->getJsonConverter()->convertObjectList($responseData); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|