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 | * Loads a content info object for the given remoteId. |
||
118 | * |
||
119 | * To load fields use loadContent |
||
120 | * |
||
121 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
122 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist |
||
123 | * |
||
124 | * @param string $remoteId |
||
125 | * |
||
126 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
127 | */ |
||
128 | View Code Duplication | public function loadContentInfoByRemoteId($remoteId) |
|
152 | |||
153 | /** |
||
154 | * Returns a complete ContentInfo based on $restContentInfo. |
||
155 | * |
||
156 | * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo |
||
157 | * |
||
158 | * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo |
||
159 | */ |
||
160 | protected function completeContentInfo(Values\RestContentInfo $restContentInfo) |
||
187 | |||
188 | /** |
||
189 | * Returns the URL of the current version referenced by |
||
190 | * $currentVersionReference. |
||
191 | * |
||
192 | * @param string $currentVersionReference |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | protected function fetchCurrentVersionUrl($currentVersionReference) |
||
209 | |||
210 | /** |
||
211 | * Checks if the given response is an error. |
||
212 | * |
||
213 | * @param Message $response |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | protected function isErrorResponse(Message $response) |
||
221 | |||
222 | /** |
||
223 | * Loads a version info of the given content object. |
||
224 | * |
||
225 | * If no version number is given, the method returns the current version |
||
226 | * |
||
227 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
228 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
229 | * |
||
230 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
231 | * @param int $versionNo the version number. If not given the current version is returned. |
||
232 | * |
||
233 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
234 | */ |
||
235 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null) |
||
239 | |||
240 | /** |
||
241 | * Loads a version info of the given content object id. |
||
242 | * |
||
243 | * If no version number is given, the method returns the current version |
||
244 | * |
||
245 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
246 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
247 | * |
||
248 | * @param mixed $contentId |
||
249 | * @param int $versionNo the version number. If not given the current version is returned. |
||
250 | * |
||
251 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
252 | */ |
||
253 | public function loadVersionInfoById($contentId, $versionNo = null) |
||
257 | |||
258 | /** |
||
259 | * Loads content in a version for the given content info object. |
||
260 | * |
||
261 | * If no version number is given, the method returns the current version |
||
262 | * |
||
263 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist |
||
264 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
265 | * |
||
266 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
267 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
268 | * @param int $versionNo the version number. If not given the current version is returned |
||
269 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
270 | * |
||
271 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
272 | */ |
||
273 | public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
281 | |||
282 | /** |
||
283 | * Loads content in the version given by version info. |
||
284 | * |
||
285 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
286 | * |
||
287 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
288 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
289 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
290 | * |
||
291 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
292 | */ |
||
293 | public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true) |
||
299 | |||
300 | /** |
||
301 | * Loads content in a version of the given content object. |
||
302 | * |
||
303 | * If no version number is given, the method returns the current version |
||
304 | * |
||
305 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist |
||
306 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
307 | * |
||
308 | * @param int $contentId |
||
309 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
310 | * @param int $versionNo the version number. If not given the current version is returned |
||
311 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
312 | * |
||
313 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
314 | * |
||
315 | * @todo Handle $versionNo = null |
||
316 | * @todo Handle language filters |
||
317 | */ |
||
318 | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
353 | |||
354 | /** |
||
355 | * Loads content in a version for the content object reference by the given remote id. |
||
356 | * |
||
357 | * If no version is given, the method returns the current version |
||
358 | * |
||
359 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist |
||
360 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
361 | * |
||
362 | * @param string $remoteId |
||
363 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
364 | * @param int $versionNo the version number. If not given the current version is returned |
||
365 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
366 | * |
||
367 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
368 | */ |
||
369 | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
375 | |||
376 | /** |
||
377 | * Creates a new content draft assigned to the authenticated user. |
||
378 | * |
||
379 | * If a different userId is given in $contentCreateStruct it is assigned to the given user |
||
380 | * but this required special rights for the authenticated user |
||
381 | * (this is useful for content staging where the transfer process does not |
||
382 | * have to authenticate with the user which created the content object in the source server). |
||
383 | * The user has to publish the draft if it should be visible. |
||
384 | * In 4.x at least one location has to be provided in the location creation array. |
||
385 | * |
||
386 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
387 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system |
||
388 | * or there is no location provided (4.x) or multiple locations |
||
389 | * are under the same parent or if the a field value is not accepted by the field type |
||
390 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid |
||
391 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing |
||
392 | * |
||
393 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
394 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content |
||
395 | * |
||
396 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
397 | */ |
||
398 | public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array()) |
||
402 | |||
403 | /** |
||
404 | * Updates the metadata. |
||
405 | * |
||
406 | * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent |
||
407 | * |
||
408 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data |
||
409 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists |
||
410 | * |
||
411 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
412 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct |
||
413 | * |
||
414 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes |
||
415 | */ |
||
416 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) |
||
420 | |||
421 | /** |
||
422 | * Deletes a content object including all its versions and locations including their subtrees. |
||
423 | * |
||
424 | * @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) |
||
425 | * |
||
426 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
427 | */ |
||
428 | public function deleteContent(ContentInfo $contentInfo) |
||
432 | |||
433 | /** |
||
434 | * Creates a draft from a published or archived version. |
||
435 | * |
||
436 | * If no version is given, the current published version is used. |
||
437 | * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language. |
||
438 | * It can be changed on updating the version. |
||
439 | * |
||
440 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft |
||
441 | * |
||
442 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
443 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
444 | * @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 |
||
445 | * |
||
446 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
447 | */ |
||
448 | public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null) |
||
452 | |||
453 | /** |
||
454 | * Loads drafts for a user. |
||
455 | * |
||
456 | * If no user is given the drafts for the authenticated user a returned |
||
457 | * |
||
458 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list |
||
459 | * |
||
460 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
461 | * |
||
462 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user |
||
463 | */ |
||
464 | public function loadContentDrafts(User $user = null) |
||
468 | |||
469 | /** |
||
470 | * Updates the fields of a draft. |
||
471 | * |
||
472 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version |
||
473 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
474 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid |
||
475 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value |
||
476 | * |
||
477 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
478 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
479 | * |
||
480 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields |
||
481 | */ |
||
482 | public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct) |
||
486 | |||
487 | /** |
||
488 | * Publishes a content version. |
||
489 | * |
||
490 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
491 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
492 | * |
||
493 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
494 | * |
||
495 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
496 | * |
||
497 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
498 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
499 | */ |
||
500 | public function publishVersion(VersionInfo $versionInfo) |
||
504 | |||
505 | /** |
||
506 | * Removes the given version. |
||
507 | * |
||
508 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in |
||
509 | * published state or is a last version of the Content |
||
510 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version |
||
511 | * |
||
512 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
513 | */ |
||
514 | public function deleteVersion(VersionInfo $versionInfo) |
||
518 | |||
519 | /** |
||
520 | * Loads all versions for the given content. |
||
521 | * |
||
522 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions |
||
523 | * |
||
524 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
525 | * |
||
526 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date |
||
527 | */ |
||
528 | public function loadVersions(ContentInfo $contentInfo) |
||
532 | |||
533 | /** |
||
534 | * Copies the content to a new location. If no version is given, |
||
535 | * all versions are copied, otherwise only the given version. |
||
536 | * |
||
537 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location |
||
538 | * |
||
539 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
540 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to |
||
541 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
542 | * |
||
543 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
544 | */ |
||
545 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null) |
||
549 | |||
550 | /** |
||
551 | * Finds content objects for the given query. |
||
552 | * |
||
553 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
554 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
555 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
556 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
557 | * |
||
558 | * @return \eZ\Publish\API\Repository\Values\Content\SearchResult |
||
559 | */ |
||
560 | public function findContent(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
564 | |||
565 | /** |
||
566 | * Performs a query for a single content object. |
||
567 | * |
||
568 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions |
||
569 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result |
||
570 | * |
||
571 | * @param \eZ\Publish\API\Repository\Values\Content\Query $query |
||
572 | * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. |
||
573 | * Currently supported: <code>array("languages" => array(<language1>,..))</code>. |
||
574 | * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. |
||
575 | * |
||
576 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
577 | */ |
||
578 | public function findSingle(Query $query, array $languageFilter, $filterOnUserPermissions = true) |
||
582 | |||
583 | /** |
||
584 | * Loads all outgoing relations for the given version. |
||
585 | * |
||
586 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
587 | * |
||
588 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
589 | * |
||
590 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
591 | */ |
||
592 | public function loadRelations(VersionInfo $versionInfo) |
||
596 | |||
597 | /** |
||
598 | * Loads all incoming relations for a content object. |
||
599 | * |
||
600 | * The relations come only |
||
601 | * from published versions of the source content objects |
||
602 | * |
||
603 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
604 | * |
||
605 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
606 | * |
||
607 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
608 | */ |
||
609 | public function loadReverseRelations(ContentInfo $contentInfo) |
||
613 | |||
614 | /** |
||
615 | * Adds a relation of type common. |
||
616 | * |
||
617 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version |
||
618 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
619 | * |
||
620 | * The source of the relation is the content and version |
||
621 | * referenced by $versionInfo. |
||
622 | * |
||
623 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
624 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation |
||
625 | * |
||
626 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation |
||
627 | */ |
||
628 | public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
632 | |||
633 | /** |
||
634 | * Removes a relation of type COMMON from a draft. |
||
635 | * |
||
636 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version |
||
637 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
638 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination |
||
639 | * |
||
640 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
641 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent |
||
642 | */ |
||
643 | public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
647 | |||
648 | /** |
||
649 | * Instantiates a new content create struct object. |
||
650 | * |
||
651 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable |
||
652 | * |
||
653 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
654 | * @param string $mainLanguageCode |
||
655 | * |
||
656 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct |
||
657 | */ |
||
658 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode) |
||
662 | |||
663 | /** |
||
664 | * Instantiates a new content meta data update struct. |
||
665 | * |
||
666 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct |
||
667 | */ |
||
668 | public function newContentMetadataUpdateStruct() |
||
672 | |||
673 | /** |
||
674 | * Instantiates a new content update struct. |
||
675 | * |
||
676 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct |
||
677 | */ |
||
678 | public function newContentUpdateStruct() |
||
682 | |||
683 | // Ignore this eZ Publish 5 feature by now. |
||
684 | |||
685 | // @codeCoverageIgnoreStart |
||
686 | |||
687 | /** |
||
688 | * {@inheritdoc} |
||
689 | */ |
||
690 | public function removeTranslation(ContentInfo $contentInfo, $languageCode) |
||
694 | |||
695 | /** |
||
696 | * {@inheritdoc} |
||
697 | */ |
||
698 | public function deleteTranslation(ContentInfo $contentInfo, $languageCode) |
||
702 | |||
703 | /** |
||
704 | * {@inheritdoc} |
||
705 | */ |
||
706 | public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode) |
||
710 | |||
711 | /** |
||
712 | * Bulk-load Content items by the list of ContentInfo Value Objects. |
||
713 | * |
||
714 | * Note: it does not throw exceptions on load, just ignores erroneous Content item. |
||
715 | * |
||
716 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList |
||
717 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on |
||
718 | * returned value object. If not given all languages are returned. |
||
719 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true, |
||
720 | * unless all languages have been asked for. |
||
721 | * |
||
722 | * @throws \Exception Not implemented |
||
723 | */ |
||
724 | public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true) |
||
728 | |||
729 | /** |
||
730 | * Instantiates a new TranslationInfo object. |
||
731 | * |
||
732 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo |
||
733 | */ |
||
734 | public function newTranslationInfo() |
||
738 | |||
739 | /** |
||
740 | * Instantiates a Translation object. |
||
741 | * |
||
742 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues |
||
743 | */ |
||
744 | public function newTranslationValues() |
||
748 | } |
||
749 |
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.