forked from netgen/TagsBundle
/
TagsService.php
320 lines (296 loc) · 14.9 KB
/
TagsService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
namespace Netgen\TagsBundle\API\Repository;
use Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct;
use Netgen\TagsBundle\API\Repository\Values\Tags\Tag;
use Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct;
use Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct;
interface TagsService
{
/**
* Loads a tag object from its $tagId.
*
*
* @param mixed $tagId
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag
*/
public function loadTag($tagId, array $languages = null, $useAlwaysAvailable = true);
/**
* Loads a tag object from its $remoteId.
*
*
* @param string $remoteId
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag
*/
public function loadTagByRemoteId($remoteId, array $languages = null, $useAlwaysAvailable = true);
/**
* Loads a tag object from its URL.
*
*
* @param string $url
* @param string[] $languages
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag
*/
public function loadTagByUrl($url, array $languages);
/**
* Loads children of a tag object.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag If null, tags from the first level will be returned
* @param int $offset The start offset for paging
* @param int $limit The number of tags returned. If $limit = -1 all children starting at $offset are returned
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[]
*/
public function loadTagChildren(Tag $tag = null, $offset = 0, $limit = -1, array $languages = null, $useAlwaysAvailable = true);
/**
* Returns the number of children of a tag object.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag If null, tag count from the first level will be returned
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
*
* @return int
*/
public function getTagChildrenCount(Tag $tag = null, array $languages = null, $useAlwaysAvailable = true);
/**
* Loads tags by specified keyword.
*
*
* @param string $keyword The keyword to fetch tags for
* @param string $language The language to check for
* @param bool $useAlwaysAvailable Check for main language if true (default) and if tag is always available
* @param int $offset The start offset for paging
* @param int $limit The number of tags returned. If $limit = -1 all children starting at $offset are returned
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[]
*/
public function loadTagsByKeyword($keyword, $language, $useAlwaysAvailable = true, $offset = 0, $limit = -1);
/**
* Returns the number of tags by specified keyword.
*
* @param string $keyword The keyword to fetch tags count for
* @param string $language The language to check for
* @param bool $useAlwaysAvailable Check for main language if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
*
* @return int
*/
public function getTagsByKeywordCount($keyword, $language, $useAlwaysAvailable = true);
/**
* Loads synonyms of a tag object.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param int $offset The start offset for paging
* @param int $limit The number of synonyms returned. If $limit = -1 all synonyms starting at $offset are returned
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the tag is already a synonym
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[]
*/
public function loadTagSynonyms(Tag $tag, $offset = 0, $limit = -1, array $languages = null, $useAlwaysAvailable = true);
/**
* Returns the number of synonyms of a tag object.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param array|null $languages A language filter for keywords. If not given all languages are returned
* @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the tag is already a synonym
*
* @return int
*/
public function getTagSynonymCount(Tag $tag, array $languages = null, $useAlwaysAvailable = true);
/**
* Loads content related to $tag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param int $offset The start offset for paging
* @param int $limit The number of content objects returned. If $limit = -1 all content objects starting at $offset are returned
* @param bool $returnContentInfo
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*
* @return \eZ\Publish\API\Repository\Values\Content\Content[]|\eZ\Publish\API\Repository\Values\Content\ContentInfo[]
*/
public function getRelatedContent(Tag $tag, $offset = 0, $limit = -1, $returnContentInfo = false);
/**
* Returns the number of content objects related to $tag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*
* @return int
*/
public function getRelatedContentCount(Tag $tag);
/**
* Creates the new tag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct $tagCreateStruct
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to create this tag
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the remote ID already exists
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The newly created tag
*/
public function createTag(TagCreateStruct $tagCreateStruct);
/**
* Updates $tag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct $tagUpdateStruct
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to update this tag
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the remote ID already exists
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The updated tag
*/
public function updateTag(Tag $tag, TagUpdateStruct $tagUpdateStruct);
/**
* Creates a synonym for $tag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct $synonymCreateStruct
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to create a synonym
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the target tag is a synonym
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The created synonym
*/
public function addSynonym(SynonymCreateStruct $synonymCreateStruct);
/**
* Converts $tag to a synonym of $mainTag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $mainTag
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If either of specified tags is not found
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to convert tag to synonym
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If either one of the tags is a synonym
* If the main tag is a sub tag of the given tag
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The converted synonym
*/
public function convertToSynonym(Tag $tag, Tag $mainTag);
/**
* Merges the $tag into the $targetTag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $targetTag
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If either of specified tags is not found
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to merge tags
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If either one of the tags is a synonym
* If the target tag is a sub tag of the given tag
*/
public function mergeTags(Tag $tag, Tag $targetTag);
/**
* Copies the subtree starting from $tag as a new subtree of $targetParentTag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag The subtree denoted by the tag to copy
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $targetParentTag The target parent tag for the copy operation
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If either of specified tags is not found
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the target tag is a sub tag of the given tag
* If the target tag is already a parent of the given tag
* If either one of the tags is a synonym
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The newly created tag of the copied subtree
*/
public function copySubtree(Tag $tag, Tag $targetParentTag = null);
/**
* Moves the subtree to $targetParentTag.
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $targetParentTag
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If either of specified tags is not found
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to move this tag
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the target tag is a sub tag of the given tag
* If the target tag is already a parent of the given tag
* If either one of the tags is a synonym
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The updated root tag of the moved subtree
*/
public function moveSubtree(Tag $tag, Tag $targetParentTag = null);
/**
* Deletes $tag and all its descendants and synonyms.
*
* If $tag is a synonym, only the synonym is deleted
*
*
* @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this tag
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
*/
public function deleteTag(Tag $tag);
/**
* Instantiates a new tag create struct.
*
* @param mixed $parentTagId
* @param string $mainLanguageCode
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct
*/
public function newTagCreateStruct($parentTagId, $mainLanguageCode);
/**
* Instantiates a new synonym create struct.
*
* @param mixed $mainTagId
* @param string $mainLanguageCode
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct
*/
public function newSynonymCreateStruct($mainTagId, $mainLanguageCode);
/**
* Instantiates a new tag update struct.
*
* @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct
*/
public function newTagUpdateStruct();
}