Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
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 |
||
30 | class ContentService implements APIContentService, Sessionable |
||
31 | { |
||
32 | /** |
||
33 | * @var \eZ\Publish\Core\REST\Client\HttpClient |
||
34 | */ |
||
35 | private $client; |
||
36 | |||
37 | /** |
||
38 | * @var \eZ\Publish\Core\REST\Common\Input\Dispatcher |
||
39 | */ |
||
40 | private $inputDispatcher; |
||
41 | |||
42 | /** |
||
43 | * @var \eZ\Publish\Core\REST\Common\Output\Visitor |
||
44 | */ |
||
45 | private $outputVisitor; |
||
46 | |||
47 | /** |
||
48 | * @var \eZ\Publish\Core\REST\Common\RequestParser |
||
49 | */ |
||
50 | private $requestParser; |
||
51 | |||
52 | /** |
||
53 | * @var \eZ\Publish\Core\REST\Client\ContentTypeService |
||
54 | */ |
||
55 | private $contentTypeService; |
||
56 | |||
57 | /** |
||
58 | * @param \eZ\Publish\Core\REST\Client\HttpClient $client |
||
59 | * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher |
||
60 | * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor |
||
61 | * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser |
||
62 | * @param \eZ\Publish\Core\REST\Client\ContentTypeService $contentTypeService |
||
63 | */ |
||
64 | View Code Duplication | public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser, ContentTypeService $contentTypeService) |
|
72 | |||
73 | /** |
||
74 | * Set session ID. |
||
75 | * |
||
76 | * Only for testing |
||
77 | * |
||
78 | * @param mixed $id |
||
79 | * |
||
80 | * @private |
||
81 | */ |
||
82 | public function setSession($id) |
||
88 | |||
89 | /** |
||
90 | * Loads a content info object. |
||
91 | * |
||
92 | * To load fields use loadContent |
||
93 | * |
||
94 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
95 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
96 | * |
||
97 | * @param int $contentId |
||
98 | * |
||
99 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
100 | */ |
||
101 | public function loadContentInfo($contentId) |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function loadContentInfoList(array $contentIds): iterable |
||
120 | { |
||
121 | throw new \Exception('@todo: Implement.'); |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Loads a content info object for the given remoteId. |
||
126 | * |
||
127 | * To load fields use loadContent |
||
128 | * |
||
129 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
130 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist |
||
131 | * |
||
132 | * @param string $remoteId |
||
133 | * |
||
134 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
135 | */ |
||
136 | View Code Duplication | public function loadContentInfoByRemoteId($remoteId) |
|
160 | |||
161 | /** |
||
162 | * Returns a complete ContentInfo based on $restContentInfo. |
||
163 | * |
||
164 | * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo |
||
165 | * |
||
166 | * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo |
||
167 | */ |
||
168 | protected function completeContentInfo(Values\RestContentInfo $restContentInfo) |
||
195 | |||
196 | /** |
||
197 | * Returns the URL of the current version referenced by |
||
198 | * $currentVersionReference. |
||
199 | * |
||
200 | * @param string $currentVersionReference |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | protected function fetchCurrentVersionUrl($currentVersionReference) |
||
217 | |||
218 | /** |
||
219 | * Checks if the given response is an error. |
||
220 | * |
||
221 | * @param Message $response |
||
222 | * |
||
223 | * @return bool |
||
224 | */ |
||
225 | protected function isErrorResponse(Message $response) |
||
229 | |||
230 | /** |
||
231 | * Loads a version info of the given content object. |
||
232 | * |
||
233 | * If no version number is given, the method returns the current version |
||
234 | * |
||
235 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
236 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
237 | * |
||
238 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
239 | * @param int $versionNo the version number. If not given the current version is returned. |
||
240 | * |
||
241 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
242 | */ |
||
243 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null) |
||
247 | |||
248 | /** |
||
249 | * Loads a version info of the given content object id. |
||
250 | * |
||
251 | * If no version number is given, the method returns the current version |
||
252 | * |
||
253 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
254 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
255 | * |
||
256 | * @param mixed $contentId |
||
257 | * @param int $versionNo the version number. If not given the current version is returned. |
||
258 | * |
||
259 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
260 | */ |
||
261 | public function loadVersionInfoById($contentId, $versionNo = null) |
||
265 | |||
266 | /** |
||
267 | * Loads content in a version for the given content info object. |
||
268 | * |
||
269 | * If no version number is given, the method returns the current version |
||
270 | * |
||
271 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist |
||
272 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
273 | * |
||
274 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
275 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
276 | * @param int $versionNo the version number. If not given the current version is returned |
||
277 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
278 | * |
||
279 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
280 | */ |
||
281 | public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
289 | |||
290 | /** |
||
291 | * Loads content in the version given by version info. |
||
292 | * |
||
293 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
294 | * |
||
295 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
296 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
297 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
298 | * |
||
299 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
300 | */ |
||
301 | public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true) |
||
307 | |||
308 | /** |
||
309 | * Loads content in a version of the given content object. |
||
310 | * |
||
311 | * If no version number is given, the method returns the current version |
||
312 | * |
||
313 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist |
||
314 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
315 | * |
||
316 | * @param int $contentId |
||
317 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
318 | * @param int $versionNo the version number. If not given the current version is returned |
||
319 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
320 | * |
||
321 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
322 | * |
||
323 | * @todo Handle $versionNo = null |
||
324 | * @todo Handle language filters |
||
325 | */ |
||
326 | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
361 | |||
362 | /** |
||
363 | * Loads content in a version for the content object reference by the given remote id. |
||
364 | * |
||
365 | * If no version is given, the method returns the current version |
||
366 | * |
||
367 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist |
||
368 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
369 | * |
||
370 | * @param string $remoteId |
||
371 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
372 | * @param int $versionNo the version number. If not given the current version is returned |
||
373 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
374 | * |
||
375 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
376 | */ |
||
377 | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
383 | |||
384 | /** |
||
385 | * Creates a new content draft assigned to the authenticated user. |
||
386 | * |
||
387 | * If a different userId is given in $contentCreateStruct it is assigned to the given user |
||
388 | * but this required special rights for the authenticated user |
||
389 | * (this is useful for content staging where the transfer process does not |
||
390 | * have to authenticate with the user which created the content object in the source server). |
||
391 | * The user has to publish the draft if it should be visible. |
||
392 | * In 4.x at least one location has to be provided in the location creation array. |
||
393 | * |
||
394 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
395 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system |
||
396 | * or there is no location provided (4.x) or multiple locations |
||
397 | * are under the same parent or if the a field value is not accepted by the field type |
||
398 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid |
||
399 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing |
||
400 | * |
||
401 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
402 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content |
||
403 | * |
||
404 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
405 | */ |
||
406 | public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array()) |
||
410 | |||
411 | /** |
||
412 | * Updates the metadata. |
||
413 | * |
||
414 | * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent |
||
415 | * |
||
416 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data |
||
417 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists |
||
418 | * |
||
419 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
420 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct |
||
421 | * |
||
422 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes |
||
423 | */ |
||
424 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) |
||
428 | |||
429 | /** |
||
430 | * Deletes a content object including all its versions and locations including their subtrees. |
||
431 | * |
||
432 | * @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) |
||
433 | * |
||
434 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
435 | */ |
||
436 | public function deleteContent(ContentInfo $contentInfo) |
||
440 | |||
441 | /** |
||
442 | * Creates a draft from a published or archived version. |
||
443 | * |
||
444 | * If no version is given, the current published version is used. |
||
445 | * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language. |
||
446 | * It can be changed on updating the version. |
||
447 | * |
||
448 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft |
||
449 | * |
||
450 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
451 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
452 | * @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 |
||
453 | * |
||
454 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
455 | */ |
||
456 | public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null) |
||
460 | |||
461 | /** |
||
462 | * Loads drafts for a user. |
||
463 | * |
||
464 | * If no user is given the drafts for the authenticated user a returned |
||
465 | * |
||
466 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list |
||
467 | * |
||
468 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
469 | * |
||
470 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user |
||
471 | */ |
||
472 | public function loadContentDrafts(User $user = null) |
||
476 | |||
477 | /** |
||
478 | * Updates the fields of a draft. |
||
479 | * |
||
480 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version |
||
481 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
482 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid |
||
483 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value |
||
484 | * |
||
485 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
486 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
487 | * |
||
488 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields |
||
489 | */ |
||
490 | public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct) |
||
494 | |||
495 | /** |
||
496 | * Publishes a content version. |
||
497 | * |
||
498 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
499 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
500 | * |
||
501 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
502 | * |
||
503 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
504 | * |
||
505 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
506 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
507 | */ |
||
508 | public function publishVersion(VersionInfo $versionInfo) |
||
512 | |||
513 | /** |
||
514 | * Removes the given version. |
||
515 | * |
||
516 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in |
||
517 | * published state or is a last version of the Content |
||
518 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version |
||
519 | * |
||
520 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
521 | */ |
||
522 | public function deleteVersion(VersionInfo $versionInfo) |
||
526 | |||
527 | /** |
||
528 | * Loads all versions for the given content. |
||
529 | * |
||
530 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions |
||
531 | * |
||
532 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
533 | * |
||
534 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date |
||
535 | */ |
||
536 | public function loadVersions(ContentInfo $contentInfo) |
||
540 | |||
541 | /** |
||
542 | * Copies the content to a new location. If no version is given, |
||
543 | * all versions are copied, otherwise only the given version. |
||
544 | * |
||
545 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location |
||
546 | * |
||
547 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
548 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to |
||
549 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
550 | * |
||
551 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
552 | */ |
||
553 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null) |
||
557 | |||
558 | /** |
||
559 | * Finds content objects for the given query. |
||
560 | * |
||
561 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
562 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
563 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
564 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
565 | * |
||
566 | * @return \eZ\Publish\API\Repository\Values\Content\SearchResult |
||
567 | */ |
||
568 | public function findContent(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
572 | |||
573 | /** |
||
574 | * Performs a query for a single content object. |
||
575 | * |
||
576 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions |
||
577 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result |
||
578 | * |
||
579 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
580 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
581 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
582 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
583 | * |
||
584 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
585 | */ |
||
586 | public function findSingle(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
590 | |||
591 | /** |
||
592 | * Loads all outgoing relations for the given version. |
||
593 | * |
||
594 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
595 | * |
||
596 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
597 | * |
||
598 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
599 | */ |
||
600 | public function loadRelations(VersionInfo $versionInfo) |
||
604 | |||
605 | /** |
||
606 | * Loads all incoming relations for a content object. |
||
607 | * |
||
608 | * The relations come only |
||
609 | * from published versions of the source content objects |
||
610 | * |
||
611 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
612 | * |
||
613 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
614 | * |
||
615 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
616 | */ |
||
617 | public function loadReverseRelations(ContentInfo $contentInfo) |
||
621 | |||
622 | /** |
||
623 | * Adds a relation of type common. |
||
624 | * |
||
625 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version |
||
626 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
627 | * |
||
628 | * The source of the relation is the content and version |
||
629 | * referenced by $versionInfo. |
||
630 | * |
||
631 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
632 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation |
||
633 | * |
||
634 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation |
||
635 | */ |
||
636 | public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
640 | |||
641 | /** |
||
642 | * Removes a relation of type COMMON from a draft. |
||
643 | * |
||
644 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version |
||
645 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
646 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination |
||
647 | * |
||
648 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
649 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent |
||
650 | */ |
||
651 | public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
655 | |||
656 | /** |
||
657 | * Instantiates a new content create struct object. |
||
658 | * |
||
659 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable |
||
660 | * |
||
661 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
662 | * @param string $mainLanguageCode |
||
663 | * |
||
664 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct |
||
665 | */ |
||
666 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode) |
||
670 | |||
671 | /** |
||
672 | * Instantiates a new content meta data update struct. |
||
673 | * |
||
674 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct |
||
675 | */ |
||
676 | public function newContentMetadataUpdateStruct() |
||
680 | |||
681 | /** |
||
682 | * Instantiates a new content update struct. |
||
683 | * |
||
684 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct |
||
685 | */ |
||
686 | public function newContentUpdateStruct() |
||
690 | |||
691 | // Ignore this eZ Publish 5 feature by now. |
||
692 | |||
693 | // @codeCoverageIgnoreStart |
||
694 | |||
695 | /** |
||
696 | * {@inheritdoc} |
||
697 | */ |
||
698 | public function removeTranslation(ContentInfo $contentInfo, $languageCode) |
||
702 | |||
703 | /** |
||
704 | * {@inheritdoc} |
||
705 | */ |
||
706 | public function deleteTranslation(ContentInfo $contentInfo, $languageCode) |
||
710 | |||
711 | /** |
||
712 | * {@inheritdoc} |
||
713 | */ |
||
714 | public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode) |
||
718 | |||
719 | /** |
||
720 | * Bulk-load Content items by the list of ContentInfo Value Objects. |
||
721 | * |
||
722 | * Note: it does not throw exceptions on load, just ignores erroneous Content item. |
||
723 | * |
||
724 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList |
||
725 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on |
||
726 | * returned value object. If not given all languages are returned. |
||
727 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true, |
||
728 | * unless all languages have been asked for. |
||
729 | * |
||
730 | * @throws \Exception Not implemented |
||
731 | */ |
||
732 | public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true) |
||
736 | |||
737 | /** |
||
738 | * Instantiates a new TranslationInfo object. |
||
739 | * |
||
740 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo |
||
741 | */ |
||
742 | public function newTranslationInfo() |
||
746 | |||
747 | /** |
||
748 | * Instantiates a Translation object. |
||
749 | * |
||
750 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues |
||
751 | */ |
||
752 | public function newTranslationValues() |
||
756 | } |
||
757 |
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.