Complex classes like ContentService often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ContentService, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
31 | class ContentService implements APIContentService, Sessionable |
||
32 | { |
||
33 | /** @var \eZ\Publish\Core\REST\Client\HttpClient */ |
||
34 | private $client; |
||
35 | |||
36 | /** @var \eZ\Publish\Core\REST\Common\Input\Dispatcher */ |
||
37 | private $inputDispatcher; |
||
38 | |||
39 | /** @var \eZ\Publish\Core\REST\Common\Output\Visitor */ |
||
40 | private $outputVisitor; |
||
41 | |||
42 | /** @var \eZ\Publish\Core\REST\Common\RequestParser */ |
||
43 | private $requestParser; |
||
44 | |||
45 | /** @var \eZ\Publish\Core\REST\Client\ContentTypeService */ |
||
46 | private $contentTypeService; |
||
47 | |||
48 | /** |
||
49 | * @param \eZ\Publish\Core\REST\Client\HttpClient $client |
||
50 | * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher |
||
51 | * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor |
||
52 | * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser |
||
53 | * @param \eZ\Publish\Core\REST\Client\ContentTypeService $contentTypeService |
||
54 | */ |
||
55 | public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser, ContentTypeService $contentTypeService) |
||
63 | |||
64 | /** |
||
65 | * Set session ID. |
||
66 | * |
||
67 | * Only for testing |
||
68 | * |
||
69 | * @param mixed $id |
||
70 | * |
||
71 | * @private |
||
72 | */ |
||
73 | public function setSession($id) |
||
79 | |||
80 | /** |
||
81 | * Loads a content info object. |
||
82 | * |
||
83 | * To load fields use loadContent |
||
84 | * |
||
85 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
86 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
87 | * |
||
88 | * @param int $contentId |
||
89 | * |
||
90 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
91 | */ |
||
92 | public function loadContentInfo($contentId) |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | public function loadContentInfoList(array $contentIds): iterable |
||
114 | |||
115 | /** |
||
116 | * Loads a content info object for the given remoteId. |
||
117 | * |
||
118 | * To load fields use loadContent |
||
119 | * |
||
120 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
121 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist |
||
122 | * |
||
123 | * @param string $remoteId |
||
124 | * |
||
125 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
126 | */ |
||
127 | public function loadContentInfoByRemoteId($remoteId) |
||
151 | |||
152 | /** |
||
153 | * Returns a complete ContentInfo based on $restContentInfo. |
||
154 | * |
||
155 | * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo |
||
156 | * |
||
157 | * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo |
||
158 | */ |
||
159 | protected function completeContentInfo(Values\RestContentInfo $restContentInfo) |
||
186 | |||
187 | /** |
||
188 | * Returns the URL of the current version referenced by |
||
189 | * $currentVersionReference. |
||
190 | * |
||
191 | * @param string $currentVersionReference |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | protected function fetchCurrentVersionUrl($currentVersionReference) |
||
208 | |||
209 | /** |
||
210 | * Checks if the given response is an error. |
||
211 | * |
||
212 | * @param Message $response |
||
213 | * |
||
214 | * @return bool |
||
215 | */ |
||
216 | protected function isErrorResponse(Message $response) |
||
220 | |||
221 | /** |
||
222 | * Loads a version info of the given content object. |
||
223 | * |
||
224 | * If no version number is given, the method returns the current version |
||
225 | * |
||
226 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
227 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
228 | * |
||
229 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
230 | * @param int $versionNo the version number. If not given the current version is returned. |
||
231 | * |
||
232 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
233 | */ |
||
234 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null) |
||
238 | |||
239 | /** |
||
240 | * Loads a version info of the given content object id. |
||
241 | * |
||
242 | * If no version number is given, the method returns the current version |
||
243 | * |
||
244 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
245 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
246 | * |
||
247 | * @param mixed $contentId |
||
248 | * @param int $versionNo the version number. If not given the current version is returned. |
||
249 | * |
||
250 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
251 | */ |
||
252 | public function loadVersionInfoById($contentId, $versionNo = null) |
||
256 | |||
257 | /** |
||
258 | * Loads content in a version for the given content info object. |
||
259 | * |
||
260 | * If no version number is given, the method returns the current version |
||
261 | * |
||
262 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist |
||
263 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
264 | * |
||
265 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
266 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
267 | * @param int $versionNo the version number. If not given the current version is returned |
||
268 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
269 | * |
||
270 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
271 | */ |
||
272 | public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
280 | |||
281 | /** |
||
282 | * Loads content in the version given by version info. |
||
283 | * |
||
284 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
285 | * |
||
286 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
287 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
288 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
289 | * |
||
290 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
291 | */ |
||
292 | public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true) |
||
298 | |||
299 | /** |
||
300 | * Loads content in a version of the given content object. |
||
301 | * |
||
302 | * If no version number is given, the method returns the current version |
||
303 | * |
||
304 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist |
||
305 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
306 | * |
||
307 | * @param int $contentId |
||
308 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
309 | * @param int $versionNo the version number. If not given the current version is returned |
||
310 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
311 | * |
||
312 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
313 | * |
||
314 | * @todo Handle $versionNo = null |
||
315 | * @todo Handle language filters |
||
316 | */ |
||
317 | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
352 | |||
353 | /** |
||
354 | * Loads content in a version for the content object reference by the given remote id. |
||
355 | * |
||
356 | * If no version is given, the method returns the current version |
||
357 | * |
||
358 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist |
||
359 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
360 | * |
||
361 | * @param string $remoteId |
||
362 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
363 | * @param int $versionNo the version number. If not given the current version is returned |
||
364 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
365 | * |
||
366 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
367 | */ |
||
368 | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
374 | |||
375 | /** |
||
376 | * Creates a new content draft assigned to the authenticated user. |
||
377 | * |
||
378 | * If a different userId is given in $contentCreateStruct it is assigned to the given user |
||
379 | * but this required special rights for the authenticated user |
||
380 | * (this is useful for content staging where the transfer process does not |
||
381 | * have to authenticate with the user which created the content object in the source server). |
||
382 | * The user has to publish the draft if it should be visible. |
||
383 | * In 4.x at least one location has to be provided in the location creation array. |
||
384 | * |
||
385 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
386 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system |
||
387 | * or there is no location provided (4.x) or multiple locations |
||
388 | * are under the same parent or if the a field value is not accepted by the field type |
||
389 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid |
||
390 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing |
||
391 | * |
||
392 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
393 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content |
||
394 | * |
||
395 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
396 | */ |
||
397 | public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = []) |
||
401 | |||
402 | /** |
||
403 | * Updates the metadata. |
||
404 | * |
||
405 | * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent |
||
406 | * |
||
407 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data |
||
408 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists |
||
409 | * |
||
410 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
411 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct |
||
412 | * |
||
413 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes |
||
414 | */ |
||
415 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) |
||
419 | |||
420 | /** |
||
421 | * Deletes a content object including all its versions and locations including their subtrees. |
||
422 | * |
||
423 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete the content (in one of the locations of the given content object) |
||
424 | * |
||
425 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
426 | */ |
||
427 | public function deleteContent(ContentInfo $contentInfo) |
||
431 | |||
432 | /** |
||
433 | * Creates a draft from a published or archived version. |
||
434 | * |
||
435 | * If no version is given, the current published version is used. |
||
436 | * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language. |
||
437 | * It can be changed on updating the version. |
||
438 | * |
||
439 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft |
||
440 | * |
||
441 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
442 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
443 | * @param \eZ\Publish\API\Repository\Values\User\User $user if set given user is used to create the draft - otherwise the current user is used |
||
444 | * |
||
445 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
446 | */ |
||
447 | public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null) |
||
451 | |||
452 | /** |
||
453 | * Counts drafts for a user. |
||
454 | * |
||
455 | * If no user is given the number of drafts for the authenticated user are returned |
||
456 | * |
||
457 | * @param \eZ\Publish\API\Repository\Values\User\User $user The user to load drafts for, if defined, otherwise drafts for current-user |
||
458 | * |
||
459 | * @return int The number of drafts ({@link VersionInfo}) owned by the given user |
||
460 | */ |
||
461 | public function countContentDrafts(?User $user = null): int |
||
465 | |||
466 | /** |
||
467 | * Loads drafts for a user. |
||
468 | * |
||
469 | * If no user is given the drafts for the authenticated user are returned |
||
470 | * |
||
471 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
472 | * |
||
473 | * |
||
474 | * @throws \Exception |
||
475 | */ |
||
476 | public function loadContentDrafts(User $user = null) |
||
480 | |||
481 | /** |
||
482 | * {@inheritdoc} |
||
483 | */ |
||
484 | public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList |
||
488 | |||
489 | /** |
||
490 | * Updates the fields of a draft. |
||
491 | * |
||
492 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version |
||
493 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
494 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid |
||
495 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value |
||
496 | * |
||
497 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
498 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
499 | * |
||
500 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields |
||
501 | */ |
||
502 | public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct) |
||
506 | |||
507 | /** |
||
508 | * Publishes a content version. |
||
509 | * |
||
510 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
511 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
512 | * |
||
513 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
514 | * @param string[] $translations |
||
515 | * |
||
516 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
517 | * |
||
518 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
519 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
520 | */ |
||
521 | public function publishVersion(VersionInfo $versionInfo, array $translations = Language::ALL) |
||
525 | |||
526 | /** |
||
527 | * Removes the given version. |
||
528 | * |
||
529 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in |
||
530 | * published state or is a last version of the Content |
||
531 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version |
||
532 | * |
||
533 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
534 | */ |
||
535 | public function deleteVersion(VersionInfo $versionInfo) |
||
539 | |||
540 | /** |
||
541 | * Loads all versions for the given content. |
||
542 | * |
||
543 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions |
||
544 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the given status is invalid |
||
545 | * |
||
546 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
547 | * @param int|null $status |
||
548 | * |
||
549 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date |
||
550 | */ |
||
551 | public function loadVersions(ContentInfo $contentInfo, ?int $status = null) |
||
555 | |||
556 | /** |
||
557 | * Copies the content to a new location. If no version is given, |
||
558 | * all versions are copied, otherwise only the given version. |
||
559 | * |
||
560 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location |
||
561 | * |
||
562 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
563 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to |
||
564 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
565 | * |
||
566 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
567 | */ |
||
568 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null) |
||
572 | |||
573 | /** |
||
574 | * Finds content objects for the given query. |
||
575 | * |
||
576 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
577 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
578 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
579 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
580 | * |
||
581 | * @return \eZ\Publish\API\Repository\Values\Content\SearchResult |
||
582 | */ |
||
583 | public function findContent(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
587 | |||
588 | /** |
||
589 | * Performs a query for a single content object. |
||
590 | * |
||
591 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions |
||
592 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result |
||
593 | * |
||
594 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
595 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
596 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
597 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
598 | * |
||
599 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
600 | */ |
||
601 | public function findSingle(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
605 | |||
606 | /** |
||
607 | * Loads all outgoing relations for the given version. |
||
608 | * |
||
609 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
610 | * |
||
611 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
612 | * |
||
613 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
614 | */ |
||
615 | public function loadRelations(VersionInfo $versionInfo) |
||
619 | |||
620 | /** |
||
621 | * Loads all incoming relations for a content object. |
||
622 | * |
||
623 | * The relations come only |
||
624 | * from published versions of the source content objects |
||
625 | * |
||
626 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
627 | * |
||
628 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
629 | * |
||
630 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
631 | */ |
||
632 | public function loadReverseRelations(ContentInfo $contentInfo) |
||
636 | |||
637 | /** |
||
638 | * Adds a relation of type common. |
||
639 | * |
||
640 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version |
||
641 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
642 | * |
||
643 | * The source of the relation is the content and version |
||
644 | * referenced by $versionInfo. |
||
645 | * |
||
646 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
647 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation |
||
648 | * |
||
649 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation |
||
650 | */ |
||
651 | public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
655 | |||
656 | /** |
||
657 | * Removes a relation of type COMMON from a draft. |
||
658 | * |
||
659 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version |
||
660 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
661 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination |
||
662 | * |
||
663 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
664 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent |
||
665 | */ |
||
666 | public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
670 | |||
671 | /** |
||
672 | * Instantiates a new content create struct object. |
||
673 | * |
||
674 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable |
||
675 | * |
||
676 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
677 | * @param string $mainLanguageCode |
||
678 | * |
||
679 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct |
||
680 | */ |
||
681 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode) |
||
685 | |||
686 | /** |
||
687 | * Instantiates a new content meta data update struct. |
||
688 | * |
||
689 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct |
||
690 | */ |
||
691 | public function newContentMetadataUpdateStruct() |
||
695 | |||
696 | /** |
||
697 | * Instantiates a new content update struct. |
||
698 | * |
||
699 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct |
||
700 | */ |
||
701 | public function newContentUpdateStruct() |
||
705 | |||
706 | // Ignore this eZ Publish 5 feature by now. |
||
707 | |||
708 | // @codeCoverageIgnoreStart |
||
709 | |||
710 | /** |
||
711 | * {@inheritdoc} |
||
712 | */ |
||
713 | public function removeTranslation(ContentInfo $contentInfo, $languageCode) |
||
717 | |||
718 | /** |
||
719 | * {@inheritdoc} |
||
720 | */ |
||
721 | public function deleteTranslation(ContentInfo $contentInfo, $languageCode) |
||
725 | |||
726 | /** |
||
727 | * {@inheritdoc} |
||
728 | */ |
||
729 | public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode) |
||
733 | |||
734 | /** |
||
735 | * Bulk-load Content items by the list of ContentInfo Value Objects. |
||
736 | * |
||
737 | * Note: it does not throw exceptions on load, just ignores erroneous Content item. |
||
738 | * |
||
739 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList |
||
740 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on |
||
741 | * returned value object. If not given all languages are returned. |
||
742 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true, |
||
743 | * unless all languages have been asked for. |
||
744 | * |
||
745 | * @throws \Exception Not implemented |
||
746 | */ |
||
747 | public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true) |
||
751 | |||
752 | /** |
||
753 | * Hides Content by making all the Locations appear hidden. |
||
754 | * It does not persist hidden state on Location object itself. |
||
755 | * |
||
756 | * Content hidden by this API can be revealed by revealContent API. |
||
757 | * |
||
758 | * @see revealContent |
||
759 | * |
||
760 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
761 | */ |
||
762 | public function hideContent(ContentInfo $contentInfo): void |
||
766 | |||
767 | /** |
||
768 | * Reveals Content hidden by hideContent API. |
||
769 | * Locations which were hidden before hiding Content will remain hidden. |
||
770 | * |
||
771 | * @see hideContent |
||
772 | * |
||
773 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
774 | */ |
||
775 | public function revealContent(ContentInfo $contentInfo): void |
||
779 | } |
||
780 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.