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 |
||
54 | class ContentService implements ContentServiceInterface |
||
55 | { |
||
56 | /** |
||
57 | * @var \eZ\Publish\Core\Repository\Repository |
||
58 | */ |
||
59 | protected $repository; |
||
60 | |||
61 | /** |
||
62 | * @var \eZ\Publish\SPI\Persistence\Handler |
||
63 | */ |
||
64 | protected $persistenceHandler; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $settings; |
||
70 | |||
71 | /** |
||
72 | * @var \eZ\Publish\Core\Repository\Helper\DomainMapper |
||
73 | */ |
||
74 | protected $domainMapper; |
||
75 | |||
76 | /** |
||
77 | * @var \eZ\Publish\Core\Repository\Helper\RelationProcessor |
||
78 | */ |
||
79 | protected $relationProcessor; |
||
80 | |||
81 | /** |
||
82 | * @var \eZ\Publish\Core\Repository\Helper\NameSchemaService |
||
83 | */ |
||
84 | protected $nameSchemaService; |
||
85 | |||
86 | /** |
||
87 | * @var \eZ\Publish\Core\Repository\Helper\FieldTypeRegistry |
||
88 | */ |
||
89 | protected $fieldTypeRegistry; |
||
90 | |||
91 | /** |
||
92 | * Setups service with reference to repository object that created it & corresponding handler. |
||
93 | * |
||
94 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
95 | * @param \eZ\Publish\SPI\Persistence\Handler $handler |
||
96 | * @param \eZ\Publish\Core\Repository\Helper\DomainMapper $domainMapper |
||
97 | * @param \eZ\Publish\Core\Repository\Helper\RelationProcessor $relationProcessor |
||
98 | * @param \eZ\Publish\Core\Repository\Helper\NameSchemaService $nameSchemaService |
||
99 | * @param \eZ\Publish\Core\Repository\Helper\FieldTypeRegistry $fieldTypeRegistry, |
||
|
|||
100 | * @param array $settings |
||
101 | */ |
||
102 | public function __construct( |
||
123 | |||
124 | /** |
||
125 | * Loads a content info object. |
||
126 | * |
||
127 | * To load fields use loadContent |
||
128 | * |
||
129 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
130 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
131 | * |
||
132 | * @param int $contentId |
||
133 | * |
||
134 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
135 | */ |
||
136 | View Code Duplication | public function loadContentInfo($contentId) |
|
145 | |||
146 | /** |
||
147 | * Loads a content info object. |
||
148 | * |
||
149 | * To load fields use loadContent |
||
150 | * |
||
151 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
152 | * |
||
153 | * @param mixed $id |
||
154 | * @param bool $isRemoteId |
||
155 | * |
||
156 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
157 | */ |
||
158 | public function internalLoadContentInfo($id, $isRemoteId = false) |
||
174 | |||
175 | /** |
||
176 | * Loads a content info object for the given remoteId. |
||
177 | * |
||
178 | * To load fields use loadContent |
||
179 | * |
||
180 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
181 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist |
||
182 | * |
||
183 | * @param string $remoteId |
||
184 | * |
||
185 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
186 | */ |
||
187 | View Code Duplication | public function loadContentInfoByRemoteId($remoteId) |
|
197 | |||
198 | /** |
||
199 | * Loads a version info of the given content object. |
||
200 | * |
||
201 | * If no version number is given, the method returns the current version |
||
202 | * |
||
203 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
204 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
205 | * |
||
206 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
207 | * @param int $versionNo the version number. If not given the current version is returned. |
||
208 | * |
||
209 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
210 | */ |
||
211 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null) |
||
215 | |||
216 | /** |
||
217 | * Loads a version info of the given content object id. |
||
218 | * |
||
219 | * If no version number is given, the method returns the current version |
||
220 | * |
||
221 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
222 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
223 | * |
||
224 | * @param mixed $contentId |
||
225 | * @param int $versionNo the version number. If not given the current version is returned. |
||
226 | * |
||
227 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
228 | */ |
||
229 | 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) |
||
295 | |||
296 | /** |
||
297 | * Loads content in the version given by version info. |
||
298 | * |
||
299 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
300 | * |
||
301 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
302 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
303 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
304 | * |
||
305 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
306 | */ |
||
307 | public function loadContentByVersionInfo(APIVersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true) |
||
321 | |||
322 | /** |
||
323 | * Loads content in a version of the given content object. |
||
324 | * |
||
325 | * If no version number is given, the method returns the current version |
||
326 | * |
||
327 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist |
||
328 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions |
||
329 | * |
||
330 | * @param int $contentId |
||
331 | * @param array|null $languages A language filter for fields. If not given all languages are returned |
||
332 | * @param int|null $versionNo the version number. If not given the current version is returned |
||
333 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
334 | * |
||
335 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
336 | */ |
||
337 | View Code Duplication | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
|
354 | |||
355 | /** |
||
356 | * Loads content in a version of the given content object. |
||
357 | * |
||
358 | * If no version number is given, the method returns the current version |
||
359 | * |
||
360 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist |
||
361 | * |
||
362 | * @param mixed $id |
||
363 | * @param array|null $languages A language filter for fields. If not given all languages are returned |
||
364 | * @param int|null $versionNo the version number. If not given the current version is returned |
||
365 | * @param bool $isRemoteId |
||
366 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
367 | * |
||
368 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
369 | */ |
||
370 | public function internalLoadContent($id, array $languages = null, $versionNo = null, $isRemoteId = false, $useAlwaysAvailable = true) |
||
418 | |||
419 | /** |
||
420 | * Loads content in a version for the content object reference by the given remote id. |
||
421 | * |
||
422 | * If no version is given, the method returns the current version |
||
423 | * |
||
424 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist |
||
425 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions |
||
426 | * |
||
427 | * @param string $remoteId |
||
428 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
429 | * @param int $versionNo the version number. If not given the current version is returned |
||
430 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
431 | * |
||
432 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
433 | */ |
||
434 | View Code Duplication | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
|
451 | |||
452 | /** |
||
453 | * Bulk-load Content items by the list of ContentInfo Value Objects. |
||
454 | * |
||
455 | * Note: it does not throw exceptions on load, just ignores erroneous Content item. |
||
456 | * Moreover, since the method works on pre-loaded ContentInfo list, it is assumed that user is |
||
457 | * allowed to access every Content on the list. |
||
458 | * |
||
459 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList |
||
460 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on |
||
461 | * returned value object. If not given all languages are returned. |
||
462 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true, |
||
463 | * unless all languages have been asked for. |
||
464 | * |
||
465 | * @return \eZ\Publish\API\Repository\Values\Content\Content[] list of Content items with Content Ids as keys |
||
466 | */ |
||
467 | public function loadContentListByContentInfo( |
||
502 | |||
503 | /** |
||
504 | * Creates a new content draft assigned to the authenticated user. |
||
505 | * |
||
506 | * If a different userId is given in $contentCreateStruct it is assigned to the given user |
||
507 | * but this required special rights for the authenticated user |
||
508 | * (this is useful for content staging where the transfer process does not |
||
509 | * have to authenticate with the user which created the content object in the source server). |
||
510 | * The user has to publish the draft if it should be visible. |
||
511 | * In 4.x at least one location has to be provided in the location creation array. |
||
512 | * |
||
513 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
514 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the provided remoteId exists in the system, required properties on |
||
515 | * struct are missing or invalid, or if multiple locations are under the |
||
516 | * same parent. |
||
517 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid, |
||
518 | * or if a required field is missing / set to an empty value. |
||
519 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType, |
||
520 | * or value is set for non-translatable field in language |
||
521 | * other than main. |
||
522 | * |
||
523 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
524 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content |
||
525 | * |
||
526 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
527 | */ |
||
528 | public function createContent(APIContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array()) |
||
726 | |||
727 | /** |
||
728 | * Returns an array of default content states with content state group id as key. |
||
729 | * |
||
730 | * @return \eZ\Publish\SPI\Persistence\Content\ObjectState[] |
||
731 | */ |
||
732 | protected function getDefaultObjectStates() |
||
747 | |||
748 | /** |
||
749 | * Returns all language codes used in given $fields. |
||
750 | * |
||
751 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value is set in main language |
||
752 | * |
||
753 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
754 | * |
||
755 | * @return string[] |
||
756 | */ |
||
757 | protected function getLanguageCodesForCreate(APIContentCreateStruct $contentCreateStruct) |
||
781 | |||
782 | /** |
||
783 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode]. |
||
784 | * |
||
785 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType |
||
786 | * or value is set for non-translatable field in language |
||
787 | * other than main |
||
788 | * |
||
789 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
790 | * |
||
791 | * @return array |
||
792 | */ |
||
793 | protected function mapFieldsForCreate(APIContentCreateStruct $contentCreateStruct) |
||
826 | |||
827 | /** |
||
828 | * Clones $field with overriding specific properties from given $overrides array. |
||
829 | * |
||
830 | * @param Field $field |
||
831 | * @param array $overrides |
||
832 | * |
||
833 | * @return Field |
||
834 | */ |
||
835 | private function cloneField(Field $field, array $overrides = array()) |
||
849 | |||
850 | /** |
||
851 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
852 | * |
||
853 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs |
||
854 | * |
||
855 | * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct[] |
||
856 | */ |
||
857 | protected function buildSPILocationCreateStructs(array $locationCreateStructs) |
||
899 | |||
900 | /** |
||
901 | * Updates the metadata. |
||
902 | * |
||
903 | * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent |
||
904 | * |
||
905 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data |
||
906 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists |
||
907 | * |
||
908 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
909 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct |
||
910 | * |
||
911 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes |
||
912 | */ |
||
913 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) |
||
999 | |||
1000 | /** |
||
1001 | * Publishes URL aliases for all locations of a given content. |
||
1002 | * |
||
1003 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
1004 | * @param bool $updatePathIdentificationString this parameter is legacy storage specific for updating |
||
1005 | * ezcontentobject_tree.path_identification_string, it is ignored by other storage engines |
||
1006 | */ |
||
1007 | protected function publishUrlAliasesForContent(APIContent $content, $updatePathIdentificationString = true) |
||
1026 | |||
1027 | /** |
||
1028 | * Deletes a content object including all its versions and locations including their subtrees. |
||
1029 | * |
||
1030 | * @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) |
||
1031 | * |
||
1032 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1033 | * |
||
1034 | * @return mixed[] Affected Location Id's |
||
1035 | */ |
||
1036 | public function deleteContent(ContentInfo $contentInfo) |
||
1062 | |||
1063 | /** |
||
1064 | * Creates a draft from a published or archived version. |
||
1065 | * |
||
1066 | * If no version is given, the current published version is used. |
||
1067 | * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language. |
||
1068 | * It can be changed on updating the version. |
||
1069 | * |
||
1070 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to create the draft |
||
1071 | * |
||
1072 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1073 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1074 | * @param \eZ\Publish\API\Repository\Values\User\User $creator if set given user is used to create the draft - otherwise the current-user is used |
||
1075 | * |
||
1076 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
1077 | */ |
||
1078 | public function createContentDraft(ContentInfo $contentInfo, APIVersionInfo $versionInfo = null, User $creator = null) |
||
1140 | |||
1141 | /** |
||
1142 | * Loads drafts for a user. |
||
1143 | * |
||
1144 | * If no user is given the drafts for the authenticated user a returned |
||
1145 | * |
||
1146 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to load the draft list |
||
1147 | * |
||
1148 | * @param \eZ\Publish\API\Repository\Values\User\UserReference $user |
||
1149 | * |
||
1150 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user |
||
1151 | */ |
||
1152 | public function loadContentDrafts(User $user = null) |
||
1177 | |||
1178 | /** |
||
1179 | * Translate a version. |
||
1180 | * |
||
1181 | * updates the destination version given in $translationInfo with the provided translated fields in $translationValues |
||
1182 | * |
||
1183 | * @example Examples/translation_5x.php |
||
1184 | * |
||
1185 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to update this version |
||
1186 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the given destination version is not a draft |
||
1187 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $translationValues is not valid, or if a required field is missing or is set to an empty value. |
||
1188 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType |
||
1189 | * or value is set for non-translatable field in language |
||
1190 | * other than main. |
||
1191 | * |
||
1192 | * @param \eZ\Publish\API\Repository\Values\Content\TranslationInfo $translationInfo |
||
1193 | * @param \eZ\Publish\API\Repository\Values\Content\TranslationValues $translationValues |
||
1194 | * @param \eZ\Publish\API\Repository\Values\User\User $modifier If set, this user is taken as modifier of the version |
||
1195 | * |
||
1196 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the translated fields |
||
1197 | * |
||
1198 | * @since 5.0 |
||
1199 | */ |
||
1200 | public function translateVersion(TranslationInfo $translationInfo, APITranslationValues $translationValues, User $modifier = null) |
||
1204 | |||
1205 | /** |
||
1206 | * Updates the fields of a draft. |
||
1207 | * |
||
1208 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version |
||
1209 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
1210 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a property on the struct is invalid. |
||
1211 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid, |
||
1212 | * or if a required field is missing / set to an empty value. |
||
1213 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType, |
||
1214 | * or value is set for non-translatable field in language |
||
1215 | * other than main. |
||
1216 | * |
||
1217 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1218 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
1219 | * |
||
1220 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields |
||
1221 | */ |
||
1222 | public function updateContent(APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct) |
||
1396 | |||
1397 | /** |
||
1398 | * Returns only updated language codes. |
||
1399 | * |
||
1400 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
1401 | * |
||
1402 | * @return array |
||
1403 | */ |
||
1404 | View Code Duplication | private function getUpdatedLanguageCodes(APIContentUpdateStruct $contentUpdateStruct) |
|
1420 | |||
1421 | /** |
||
1422 | * Returns all language codes used in given $fields. |
||
1423 | * |
||
1424 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value exists in initial language |
||
1425 | * |
||
1426 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
1427 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
1428 | * |
||
1429 | * @return array |
||
1430 | */ |
||
1431 | protected function getLanguageCodesForUpdate(APIContentUpdateStruct $contentUpdateStruct, APIContent $content) |
||
1443 | |||
1444 | /** |
||
1445 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode]. |
||
1446 | * |
||
1447 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType |
||
1448 | * or value is set for non-translatable field in language |
||
1449 | * other than main |
||
1450 | * |
||
1451 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
1452 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
1453 | * @param string $mainLanguageCode |
||
1454 | * |
||
1455 | * @return array |
||
1456 | */ |
||
1457 | protected function mapFieldsForUpdate( |
||
1495 | |||
1496 | /** |
||
1497 | * Publishes a content version. |
||
1498 | * |
||
1499 | * Publishes a content version and deletes archive versions if they overflow max archive versions. |
||
1500 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future. |
||
1501 | * |
||
1502 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version |
||
1503 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
1504 | * |
||
1505 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1506 | * |
||
1507 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1508 | */ |
||
1509 | public function publishVersion(APIVersionInfo $versionInfo) |
||
1536 | |||
1537 | /** |
||
1538 | * Publishes a content version. |
||
1539 | * |
||
1540 | * Publishes a content version and deletes archive versions if they overflow max archive versions. |
||
1541 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future. |
||
1542 | * |
||
1543 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
1544 | * |
||
1545 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1546 | * @param int|null $publicationDate If null existing date is kept if there is one, otherwise current time is used. |
||
1547 | * |
||
1548 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1549 | */ |
||
1550 | protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicationDate = null) |
||
1595 | |||
1596 | /** |
||
1597 | * Removes the given version. |
||
1598 | * |
||
1599 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in |
||
1600 | * published state or is the last version of the Content |
||
1601 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version |
||
1602 | * |
||
1603 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1604 | */ |
||
1605 | public function deleteVersion(APIVersionInfo $versionInfo) |
||
1647 | |||
1648 | /** |
||
1649 | * Loads all versions for the given content. |
||
1650 | * |
||
1651 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions |
||
1652 | * |
||
1653 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1654 | * |
||
1655 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date |
||
1656 | */ |
||
1657 | public function loadVersions(ContentInfo $contentInfo) |
||
1677 | |||
1678 | /** |
||
1679 | * Copies the content to a new location. If no version is given, |
||
1680 | * all versions are copied, otherwise only the given version. |
||
1681 | * |
||
1682 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location |
||
1683 | * |
||
1684 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1685 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to |
||
1686 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1687 | * |
||
1688 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
1689 | */ |
||
1690 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, APIVersionInfo $versionInfo = null) |
||
1741 | |||
1742 | /** |
||
1743 | * Loads all outgoing relations for the given version. |
||
1744 | * |
||
1745 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
1746 | * |
||
1747 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
1748 | * |
||
1749 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
1750 | */ |
||
1751 | public function loadRelations(APIVersionInfo $versionInfo) |
||
1786 | |||
1787 | /** |
||
1788 | * Loads all incoming relations for a content object. |
||
1789 | * |
||
1790 | * The relations come only from published versions of the source content objects |
||
1791 | * |
||
1792 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
1793 | * |
||
1794 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1795 | * |
||
1796 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
1797 | */ |
||
1798 | public function loadReverseRelations(ContentInfo $contentInfo) |
||
1824 | |||
1825 | /** |
||
1826 | * Adds a relation of type common. |
||
1827 | * |
||
1828 | * The source of the relation is the content and version |
||
1829 | * referenced by $versionInfo. |
||
1830 | * |
||
1831 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version |
||
1832 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
1833 | * |
||
1834 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
1835 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation |
||
1836 | * |
||
1837 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation |
||
1838 | */ |
||
1839 | public function addRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
1880 | |||
1881 | /** |
||
1882 | * Removes a relation of type COMMON from a draft. |
||
1883 | * |
||
1884 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version |
||
1885 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
1886 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination |
||
1887 | * |
||
1888 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
1889 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent |
||
1890 | */ |
||
1891 | public function deleteRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
1941 | |||
1942 | /** |
||
1943 | * Adds translation information to the content object. |
||
1944 | * |
||
1945 | * @example Examples/translation_5x.php |
||
1946 | * |
||
1947 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed add a translation info |
||
1948 | * |
||
1949 | * @param \eZ\Publish\API\Repository\Values\Content\TranslationInfo $translationInfo |
||
1950 | * |
||
1951 | * @since 5.0 |
||
1952 | */ |
||
1953 | public function addTranslationInfo(TranslationInfo $translationInfo) |
||
1957 | |||
1958 | /** |
||
1959 | * lists the translations done on this content object. |
||
1960 | * |
||
1961 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed read translation infos |
||
1962 | * |
||
1963 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1964 | * @param array $filter |
||
1965 | * |
||
1966 | * @todo TBD - filter by source version destination version and languages |
||
1967 | * |
||
1968 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo[] |
||
1969 | * |
||
1970 | * @since 5.0 |
||
1971 | */ |
||
1972 | public function loadTranslationInfos(ContentInfo $contentInfo, array $filter = array()) |
||
1976 | |||
1977 | /** |
||
1978 | * Instantiates a new content create struct object. |
||
1979 | * |
||
1980 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable |
||
1981 | * |
||
1982 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
1983 | * @param string $mainLanguageCode |
||
1984 | * |
||
1985 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct |
||
1986 | */ |
||
1987 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode) |
||
1997 | |||
1998 | /** |
||
1999 | * Instantiates a new content meta data update struct. |
||
2000 | * |
||
2001 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct |
||
2002 | */ |
||
2003 | public function newContentMetadataUpdateStruct() |
||
2007 | |||
2008 | /** |
||
2009 | * Instantiates a new content update struct. |
||
2010 | * |
||
2011 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct |
||
2012 | */ |
||
2013 | public function newContentUpdateStruct() |
||
2017 | |||
2018 | /** |
||
2019 | * Instantiates a new TranslationInfo object. |
||
2020 | * |
||
2021 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo |
||
2022 | */ |
||
2023 | public function newTranslationInfo() |
||
2027 | |||
2028 | /** |
||
2029 | * Instantiates a Translation object. |
||
2030 | * |
||
2031 | * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues |
||
2032 | */ |
||
2033 | public function newTranslationValues() |
||
2037 | } |
||
2038 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.