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 |
||
| 61 | class ContentService implements ContentServiceInterface |
||
| 62 | { |
||
| 63 | /** @var \eZ\Publish\Core\Repository\Repository */ |
||
| 64 | protected $repository; |
||
| 65 | |||
| 66 | /** @var \eZ\Publish\SPI\Persistence\Handler */ |
||
| 67 | protected $persistenceHandler; |
||
| 68 | |||
| 69 | /** @var array */ |
||
| 70 | protected $settings; |
||
| 71 | |||
| 72 | /** @var \eZ\Publish\Core\Repository\Helper\DomainMapper */ |
||
| 73 | protected $domainMapper; |
||
| 74 | |||
| 75 | /** @var \eZ\Publish\Core\Repository\Helper\RelationProcessor */ |
||
| 76 | protected $relationProcessor; |
||
| 77 | |||
| 78 | /** @var \eZ\Publish\Core\Repository\Helper\NameSchemaService */ |
||
| 79 | protected $nameSchemaService; |
||
| 80 | |||
| 81 | /** @var \eZ\Publish\Core\FieldType\FieldTypeRegistry */ |
||
| 82 | protected $fieldTypeRegistry; |
||
| 83 | |||
| 84 | /** @var \eZ\Publish\API\Repository\PermissionResolver */ |
||
| 85 | private $permissionResolver; |
||
| 86 | |||
| 87 | public function __construct( |
||
| 88 | RepositoryInterface $repository, |
||
| 89 | Handler $handler, |
||
| 90 | Helper\DomainMapper $domainMapper, |
||
| 91 | Helper\RelationProcessor $relationProcessor, |
||
| 92 | Helper\NameSchemaService $nameSchemaService, |
||
| 93 | FieldTypeRegistry $fieldTypeRegistry, |
||
| 94 | PermissionResolver $permissionResolver, |
||
| 95 | array $settings = [] |
||
| 96 | ) { |
||
| 97 | $this->repository = $repository; |
||
|
|
|||
| 98 | $this->persistenceHandler = $handler; |
||
| 99 | $this->domainMapper = $domainMapper; |
||
| 100 | $this->relationProcessor = $relationProcessor; |
||
| 101 | $this->nameSchemaService = $nameSchemaService; |
||
| 102 | $this->fieldTypeRegistry = $fieldTypeRegistry; |
||
| 103 | // Union makes sure default settings are ignored if provided in argument |
||
| 104 | $this->settings = $settings + [ |
||
| 105 | // Version archive limit (0-50), only enforced on publish, not on un-publish. |
||
| 106 | 'default_version_archive_limit' => 5, |
||
| 107 | ]; |
||
| 108 | $this->permissionResolver = $permissionResolver; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Loads a content info object. |
||
| 113 | * |
||
| 114 | * To load fields use loadContent |
||
| 115 | * |
||
| 116 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
| 117 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
| 118 | * |
||
| 119 | * @param int $contentId |
||
| 120 | * |
||
| 121 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
| 122 | */ |
||
| 123 | public function loadContentInfo($contentId) |
||
| 124 | { |
||
| 125 | $contentInfo = $this->internalLoadContentInfo($contentId); |
||
| 126 | if (!$this->permissionResolver->canUser('content', 'read', $contentInfo)) { |
||
| 127 | throw new UnauthorizedException('content', 'read', ['contentId' => $contentId]); |
||
| 128 | } |
||
| 129 | |||
| 130 | return $contentInfo; |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * {@inheritdoc} |
||
| 135 | */ |
||
| 136 | public function loadContentInfoList(array $contentIds): iterable |
||
| 137 | { |
||
| 138 | $contentInfoList = []; |
||
| 139 | $spiInfoList = $this->persistenceHandler->contentHandler()->loadContentInfoList($contentIds); |
||
| 140 | foreach ($spiInfoList as $id => $spiInfo) { |
||
| 141 | $contentInfo = $this->domainMapper->buildContentInfoDomainObject($spiInfo); |
||
| 142 | if ($this->permissionResolver->canUser('content', 'read', $contentInfo)) { |
||
| 143 | $contentInfoList[$id] = $contentInfo; |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | return $contentInfoList; |
||
| 148 | } |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Loads a content info object. |
||
| 152 | * |
||
| 153 | * To load fields use loadContent |
||
| 154 | * |
||
| 155 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist |
||
| 156 | * |
||
| 157 | * @param mixed $id |
||
| 158 | * @param bool $isRemoteId |
||
| 159 | * |
||
| 160 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
| 161 | */ |
||
| 162 | public function internalLoadContentInfo($id, $isRemoteId = false) |
||
| 163 | { |
||
| 164 | try { |
||
| 165 | $method = $isRemoteId ? 'loadContentInfoByRemoteId' : 'loadContentInfo'; |
||
| 166 | |||
| 167 | return $this->domainMapper->buildContentInfoDomainObject( |
||
| 168 | $this->persistenceHandler->contentHandler()->$method($id) |
||
| 169 | ); |
||
| 170 | } catch (APINotFoundException $e) { |
||
| 171 | throw new NotFoundException( |
||
| 172 | 'Content', |
||
| 173 | $id, |
||
| 174 | $e |
||
| 175 | ); |
||
| 176 | } |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Loads a content info object for the given remoteId. |
||
| 181 | * |
||
| 182 | * To load fields use loadContent |
||
| 183 | * |
||
| 184 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content |
||
| 185 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist |
||
| 186 | * |
||
| 187 | * @param string $remoteId |
||
| 188 | * |
||
| 189 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
| 190 | */ |
||
| 191 | public function loadContentInfoByRemoteId($remoteId) |
||
| 192 | { |
||
| 193 | $contentInfo = $this->internalLoadContentInfo($remoteId, true); |
||
| 194 | |||
| 195 | if (!$this->permissionResolver->canUser('content', 'read', $contentInfo)) { |
||
| 196 | throw new UnauthorizedException('content', 'read', ['remoteId' => $remoteId]); |
||
| 197 | } |
||
| 198 | |||
| 199 | return $contentInfo; |
||
| 200 | } |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Loads a version info of the given content object. |
||
| 204 | * |
||
| 205 | * If no version number is given, the method returns the current version |
||
| 206 | * |
||
| 207 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
| 208 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
| 209 | * |
||
| 210 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 211 | * @param int $versionNo the version number. If not given the current version is returned. |
||
| 212 | * |
||
| 213 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
| 214 | */ |
||
| 215 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null) |
||
| 216 | { |
||
| 217 | return $this->loadVersionInfoById($contentInfo->id, $versionNo); |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Loads a version info of the given content object id. |
||
| 222 | * |
||
| 223 | * If no version number is given, the method returns the current version |
||
| 224 | * |
||
| 225 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist |
||
| 226 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version |
||
| 227 | * |
||
| 228 | * @param mixed $contentId |
||
| 229 | * @param int $versionNo the version number. If not given the current version is returned. |
||
| 230 | * |
||
| 231 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
| 232 | */ |
||
| 233 | public function loadVersionInfoById($contentId, $versionNo = null) |
||
| 234 | { |
||
| 235 | try { |
||
| 236 | $spiVersionInfo = $this->persistenceHandler->contentHandler()->loadVersionInfo( |
||
| 237 | $contentId, |
||
| 238 | $versionNo |
||
| 239 | ); |
||
| 240 | } catch (APINotFoundException $e) { |
||
| 241 | throw new NotFoundException( |
||
| 242 | 'VersionInfo', |
||
| 243 | [ |
||
| 244 | 'contentId' => $contentId, |
||
| 245 | 'versionNo' => $versionNo, |
||
| 246 | ], |
||
| 247 | $e |
||
| 248 | ); |
||
| 249 | } |
||
| 250 | |||
| 251 | $versionInfo = $this->domainMapper->buildVersionInfoDomainObject($spiVersionInfo); |
||
| 252 | |||
| 253 | if ($versionInfo->isPublished()) { |
||
| 254 | $function = 'read'; |
||
| 255 | } else { |
||
| 256 | $function = 'versionread'; |
||
| 257 | } |
||
| 258 | |||
| 259 | if (!$this->permissionResolver->canUser('content', $function, $versionInfo)) { |
||
| 260 | throw new UnauthorizedException('content', $function, ['contentId' => $contentId]); |
||
| 261 | } |
||
| 262 | |||
| 263 | return $versionInfo; |
||
| 264 | } |
||
| 265 | |||
| 266 | /** |
||
| 267 | * {@inheritdoc} |
||
| 268 | */ |
||
| 269 | public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
| 270 | { |
||
| 271 | // Change $useAlwaysAvailable to false to avoid contentInfo lookup if we know alwaysAvailable is disabled |
||
| 272 | if ($useAlwaysAvailable && !$contentInfo->alwaysAvailable) { |
||
| 273 | $useAlwaysAvailable = false; |
||
| 274 | } |
||
| 275 | |||
| 276 | return $this->loadContent( |
||
| 277 | $contentInfo->id, |
||
| 278 | $languages, |
||
| 279 | $versionNo,// On purpose pass as-is and not use $contentInfo, to make sure to return actual current version on null |
||
| 280 | $useAlwaysAvailable |
||
| 281 | ); |
||
| 282 | } |
||
| 283 | |||
| 284 | /** |
||
| 285 | * {@inheritdoc} |
||
| 286 | */ |
||
| 287 | public function loadContentByVersionInfo(APIVersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true) |
||
| 301 | |||
| 302 | /** |
||
| 303 | * {@inheritdoc} |
||
| 304 | */ |
||
| 305 | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
| 306 | { |
||
| 307 | $content = $this->internalLoadContent($contentId, $languages, $versionNo, false, $useAlwaysAvailable); |
||
| 308 | |||
| 309 | if (!$this->permissionResolver->canUser('content', 'read', $content)) { |
||
| 310 | throw new UnauthorizedException('content', 'read', ['contentId' => $contentId]); |
||
| 311 | } |
||
| 312 | if ( |
||
| 313 | !$content->getVersionInfo()->isPublished() |
||
| 314 | && !$this->permissionResolver->canUser('content', 'versionread', $content) |
||
| 315 | ) { |
||
| 316 | throw new UnauthorizedException('content', 'versionread', ['contentId' => $contentId, 'versionNo' => $versionNo]); |
||
| 317 | } |
||
| 318 | |||
| 319 | return $content; |
||
| 320 | } |
||
| 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 | * @internal |
||
| 328 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist |
||
| 329 | * |
||
| 330 | * @param mixed $id |
||
| 331 | * @param array|null $languages A language priority, filters returned fields and is used as prioritized language code on |
||
| 332 | * returned value object. If not given all languages are returned. |
||
| 333 | * @param int|null $versionNo the version number. If not given the current version is returned |
||
| 334 | * @param bool $isRemoteId |
||
| 335 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
| 336 | * |
||
| 337 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 338 | */ |
||
| 339 | public function internalLoadContent($id, array $languages = null, $versionNo = null, $isRemoteId = false, $useAlwaysAvailable = true) |
||
| 340 | { |
||
| 341 | try { |
||
| 342 | // Get Content ID if lookup by remote ID |
||
| 343 | if ($isRemoteId) { |
||
| 344 | $spiContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($id); |
||
| 345 | $id = $spiContentInfo->id; |
||
| 346 | // Set $isRemoteId to false as the next loads will be for content id now that we have it (for exception use now) |
||
| 347 | $isRemoteId = false; |
||
| 348 | } |
||
| 349 | |||
| 350 | $loadLanguages = $languages; |
||
| 351 | $alwaysAvailableLanguageCode = null; |
||
| 352 | // Set main language on $languages filter if not empty (all) and $useAlwaysAvailable being true |
||
| 353 | // @todo Move use always available logic to SPI load methods, like done in location handler in 7.x |
||
| 354 | if (!empty($loadLanguages) && $useAlwaysAvailable) { |
||
| 355 | if (!isset($spiContentInfo)) { |
||
| 356 | $spiContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($id); |
||
| 357 | } |
||
| 358 | |||
| 359 | if ($spiContentInfo->alwaysAvailable) { |
||
| 360 | $loadLanguages[] = $alwaysAvailableLanguageCode = $spiContentInfo->mainLanguageCode; |
||
| 361 | $loadLanguages = array_unique($loadLanguages); |
||
| 362 | } |
||
| 363 | } |
||
| 364 | |||
| 365 | $spiContent = $this->persistenceHandler->contentHandler()->load( |
||
| 366 | $id, |
||
| 367 | $versionNo, |
||
| 368 | $loadLanguages |
||
| 369 | ); |
||
| 370 | } catch (APINotFoundException $e) { |
||
| 371 | throw new NotFoundException( |
||
| 372 | 'Content', |
||
| 373 | [ |
||
| 374 | $isRemoteId ? 'remoteId' : 'id' => $id, |
||
| 375 | 'languages' => $languages, |
||
| 376 | 'versionNo' => $versionNo, |
||
| 377 | ], |
||
| 378 | $e |
||
| 379 | ); |
||
| 380 | } |
||
| 381 | |||
| 382 | if ($languages === null) { |
||
| 383 | $languages = []; |
||
| 384 | } |
||
| 385 | |||
| 386 | return $this->domainMapper->buildContentDomainObject( |
||
| 387 | $spiContent, |
||
| 388 | $this->repository->getContentTypeService()->loadContentType( |
||
| 389 | $spiContent->versionInfo->contentInfo->contentTypeId, |
||
| 390 | $languages |
||
| 391 | ), |
||
| 392 | $languages, |
||
| 393 | $alwaysAvailableLanguageCode |
||
| 394 | ); |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Loads content in a version for the content object reference by the given remote id. |
||
| 399 | * |
||
| 400 | * If no version is given, the method returns the current version |
||
| 401 | * |
||
| 402 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist |
||
| 403 | * @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 |
||
| 404 | * |
||
| 405 | * @param string $remoteId |
||
| 406 | * @param array $languages A language filter for fields. If not given all languages are returned |
||
| 407 | * @param int $versionNo the version number. If not given the current version is returned |
||
| 408 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true |
||
| 409 | * |
||
| 410 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 411 | */ |
||
| 412 | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
||
| 429 | |||
| 430 | /** |
||
| 431 | * Bulk-load Content items by the list of ContentInfo Value Objects. |
||
| 432 | * |
||
| 433 | * Note: it does not throw exceptions on load, just ignores erroneous Content item. |
||
| 434 | * Moreover, since the method works on pre-loaded ContentInfo list, it is assumed that user is |
||
| 435 | * allowed to access every Content on the list. |
||
| 436 | * |
||
| 437 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList |
||
| 438 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on |
||
| 439 | * returned value object. If not given all languages are returned. |
||
| 440 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true, |
||
| 441 | * unless all languages have been asked for. |
||
| 442 | * |
||
| 443 | * @return \eZ\Publish\API\Repository\Values\Content\Content[] list of Content items with Content Ids as keys |
||
| 444 | */ |
||
| 445 | public function loadContentListByContentInfo( |
||
| 486 | |||
| 487 | /** |
||
| 488 | * Creates a new content draft assigned to the authenticated user. |
||
| 489 | * |
||
| 490 | * If a different userId is given in $contentCreateStruct it is assigned to the given user |
||
| 491 | * but this required special rights for the authenticated user |
||
| 492 | * (this is useful for content staging where the transfer process does not |
||
| 493 | * have to authenticate with the user which created the content object in the source server). |
||
| 494 | * The user has to publish the draft if it should be visible. |
||
| 495 | * In 4.x at least one location has to be provided in the location creation array. |
||
| 496 | * |
||
| 497 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location |
||
| 498 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the provided remoteId exists in the system, required properties on |
||
| 499 | * struct are missing or invalid, or if multiple locations are under the |
||
| 500 | * same parent. |
||
| 501 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid, |
||
| 502 | * or if a required field is missing / set to an empty value. |
||
| 503 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType, |
||
| 504 | * or value is set for non-translatable field in language |
||
| 505 | * other than main. |
||
| 506 | * |
||
| 507 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
| 508 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content |
||
| 509 | * |
||
| 510 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
| 511 | */ |
||
| 512 | public function createContent(APIContentCreateStruct $contentCreateStruct, array $locationCreateStructs = []) |
||
| 714 | |||
| 715 | /** |
||
| 716 | * Returns an array of default content states with content state group id as key. |
||
| 717 | * |
||
| 718 | * @return \eZ\Publish\SPI\Persistence\Content\ObjectState[] |
||
| 719 | */ |
||
| 720 | protected function getDefaultObjectStates() |
||
| 735 | |||
| 736 | /** |
||
| 737 | * Returns all language codes used in given $fields. |
||
| 738 | * |
||
| 739 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value is set in main language |
||
| 740 | * |
||
| 741 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
| 742 | * |
||
| 743 | * @return string[] |
||
| 744 | */ |
||
| 745 | protected function getLanguageCodesForCreate(APIContentCreateStruct $contentCreateStruct) |
||
| 769 | |||
| 770 | /** |
||
| 771 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode]. |
||
| 772 | * |
||
| 773 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType |
||
| 774 | * or value is set for non-translatable field in language |
||
| 775 | * other than main |
||
| 776 | * |
||
| 777 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct |
||
| 778 | * |
||
| 779 | * @return array |
||
| 780 | */ |
||
| 781 | protected function mapFieldsForCreate(APIContentCreateStruct $contentCreateStruct) |
||
| 814 | |||
| 815 | /** |
||
| 816 | * Clones $field with overriding specific properties from given $overrides array. |
||
| 817 | * |
||
| 818 | * @param Field $field |
||
| 819 | * @param array $overrides |
||
| 820 | * |
||
| 821 | * @return Field |
||
| 822 | */ |
||
| 823 | private function cloneField(Field $field, array $overrides = []) |
||
| 838 | |||
| 839 | /** |
||
| 840 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 841 | * |
||
| 842 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs |
||
| 843 | * |
||
| 844 | * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct[] |
||
| 845 | */ |
||
| 846 | protected function buildSPILocationCreateStructs(array $locationCreateStructs) |
||
| 888 | |||
| 889 | /** |
||
| 890 | * Updates the metadata. |
||
| 891 | * |
||
| 892 | * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent |
||
| 893 | * |
||
| 894 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data |
||
| 895 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists |
||
| 896 | * |
||
| 897 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 898 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct |
||
| 899 | * |
||
| 900 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes |
||
| 901 | */ |
||
| 902 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) |
||
| 989 | |||
| 990 | /** |
||
| 991 | * Publishes URL aliases for all locations of a given content. |
||
| 992 | * |
||
| 993 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
| 994 | * @param bool $updatePathIdentificationString this parameter is legacy storage specific for updating |
||
| 995 | * ezcontentobject_tree.path_identification_string, it is ignored by other storage engines |
||
| 996 | */ |
||
| 997 | protected function publishUrlAliasesForContent(APIContent $content, $updatePathIdentificationString = true) |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Deletes a content object including all its versions and locations including their subtrees. |
||
| 1026 | * |
||
| 1027 | * @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) |
||
| 1028 | * |
||
| 1029 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 1030 | * |
||
| 1031 | * @return mixed[] Affected Location Id's |
||
| 1032 | */ |
||
| 1033 | public function deleteContent(ContentInfo $contentInfo) |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Creates a draft from a published or archived version. |
||
| 1063 | * |
||
| 1064 | * If no version is given, the current published version is used. |
||
| 1065 | * |
||
| 1066 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 1067 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1068 | * @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 |
||
| 1069 | * @param \eZ\Publish\API\Repository\Values\Content\Language|null if not set the draft is created with the initialLanguage code of the source version or if not present with the main language. |
||
| 1070 | * |
||
| 1071 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft |
||
| 1072 | * |
||
| 1073 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1074 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the current-user is not allowed to create the draft |
||
| 1075 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to create the draft |
||
| 1076 | */ |
||
| 1077 | public function createContentDraft( |
||
| 1078 | ContentInfo $contentInfo, |
||
| 1079 | APIVersionInfo $versionInfo = null, |
||
| 1080 | User $creator = null, |
||
| 1081 | ?Language $language = null |
||
| 1082 | ) { |
||
| 1083 | $contentInfo = $this->loadContentInfo($contentInfo->id); |
||
| 1084 | |||
| 1085 | if ($versionInfo !== null) { |
||
| 1086 | // Check that given $contentInfo and $versionInfo belong to the same content |
||
| 1087 | if ($versionInfo->getContentInfo()->id != $contentInfo->id) { |
||
| 1088 | throw new InvalidArgumentException( |
||
| 1089 | '$versionInfo', |
||
| 1090 | 'VersionInfo does not belong to the same Content item as the given ContentInfo' |
||
| 1091 | ); |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | $versionInfo = $this->loadVersionInfoById($contentInfo->id, $versionInfo->versionNo); |
||
| 1095 | |||
| 1096 | switch ($versionInfo->status) { |
||
| 1097 | case VersionInfo::STATUS_PUBLISHED: |
||
| 1098 | case VersionInfo::STATUS_ARCHIVED: |
||
| 1099 | break; |
||
| 1100 | |||
| 1101 | default: |
||
| 1102 | // @todo: throw an exception here, to be defined |
||
| 1103 | throw new BadStateException( |
||
| 1104 | '$versionInfo', |
||
| 1105 | 'Cannot create a draft from a draft version' |
||
| 1106 | ); |
||
| 1107 | } |
||
| 1108 | |||
| 1109 | $versionNo = $versionInfo->versionNo; |
||
| 1110 | } elseif ($contentInfo->published) { |
||
| 1111 | $versionNo = $contentInfo->currentVersionNo; |
||
| 1112 | } else { |
||
| 1113 | // @todo: throw an exception here, to be defined |
||
| 1114 | throw new BadStateException( |
||
| 1115 | '$contentInfo', |
||
| 1116 | 'Content is not published. A draft can be created only from a published or archived version.' |
||
| 1117 | ); |
||
| 1118 | } |
||
| 1119 | |||
| 1120 | if ($creator === null) { |
||
| 1121 | $creator = $this->permissionResolver->getCurrentUserReference(); |
||
| 1122 | } |
||
| 1123 | |||
| 1124 | $fallbackLanguageCode = $versionInfo->initialLanguageCode ?? $contentInfo->mainLanguageCode; |
||
| 1125 | $languageCode = $language->languageCode ?? $fallbackLanguageCode; |
||
| 1126 | |||
| 1127 | if (!$this->permissionResolver->canUser( |
||
| 1128 | 'content', |
||
| 1129 | 'edit', |
||
| 1130 | $contentInfo, |
||
| 1131 | [ |
||
| 1132 | (new Target\Builder\VersionBuilder()) |
||
| 1133 | ->changeStatusTo(APIVersionInfo::STATUS_DRAFT) |
||
| 1134 | ->build(), |
||
| 1135 | ] |
||
| 1136 | )) { |
||
| 1137 | throw new UnauthorizedException( |
||
| 1138 | 'content', |
||
| 1139 | 'edit', |
||
| 1140 | ['contentId' => $contentInfo->id] |
||
| 1141 | ); |
||
| 1142 | } |
||
| 1143 | |||
| 1144 | $this->repository->beginTransaction(); |
||
| 1145 | try { |
||
| 1146 | $spiContent = $this->persistenceHandler->contentHandler()->createDraftFromVersion( |
||
| 1147 | $contentInfo->id, |
||
| 1148 | $versionNo, |
||
| 1149 | $creator->getUserId(), |
||
| 1150 | $languageCode |
||
| 1151 | ); |
||
| 1152 | $this->repository->commit(); |
||
| 1153 | } catch (Exception $e) { |
||
| 1154 | $this->repository->rollback(); |
||
| 1155 | throw $e; |
||
| 1156 | } |
||
| 1157 | |||
| 1158 | return $this->domainMapper->buildContentDomainObject( |
||
| 1159 | $spiContent, |
||
| 1160 | $this->repository->getContentTypeService()->loadContentType( |
||
| 1161 | $spiContent->versionInfo->contentInfo->contentTypeId |
||
| 1162 | ) |
||
| 1163 | ); |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | public function countContentDrafts(?User $user = null): int |
||
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Loads drafts for a user. |
||
| 1179 | * |
||
| 1180 | * If no user is given the drafts for the authenticated user are returned |
||
| 1181 | * |
||
| 1182 | * @param \eZ\Publish\API\Repository\Values\User\User|null $user |
||
| 1183 | * |
||
| 1184 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Drafts owned by the given user |
||
| 1185 | * |
||
| 1186 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
| 1187 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1188 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 1189 | */ |
||
| 1190 | public function loadContentDrafts(User $user = null) |
||
| 1213 | |||
| 1214 | public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList |
||
| 1215 | { |
||
| 1216 | $list = new ContentDraftList(); |
||
| 1246 | |||
| 1247 | /** |
||
| 1248 | * Updates the fields of a draft. |
||
| 1249 | * |
||
| 1250 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1251 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
| 1252 | * |
||
| 1253 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields |
||
| 1254 | * |
||
| 1255 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid, |
||
| 1256 | * or if a required field is missing / set to an empty value. |
||
| 1257 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType, |
||
| 1258 | * or value is set for non-translatable field in language |
||
| 1259 | * other than main. |
||
| 1260 | * |
||
| 1261 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version |
||
| 1262 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 1263 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a property on the struct is invalid. |
||
| 1264 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1265 | */ |
||
| 1266 | public function updateContent(APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct) |
||
| 1293 | |||
| 1294 | /** |
||
| 1295 | * Updates the fields of a draft without checking the permissions. |
||
| 1296 | * |
||
| 1297 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid, |
||
| 1298 | * or if a required field is missing / set to an empty value. |
||
| 1299 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType, |
||
| 1300 | * or value is set for non-translatable field in language |
||
| 1301 | * other than main. |
||
| 1302 | * |
||
| 1303 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 1304 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a property on the struct is invalid. |
||
| 1305 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1306 | */ |
||
| 1307 | protected function internalUpdateContent(APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct): Content |
||
| 1478 | |||
| 1479 | /** |
||
| 1480 | * Returns only updated language codes. |
||
| 1481 | * |
||
| 1482 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
| 1483 | * |
||
| 1484 | * @return array |
||
| 1485 | */ |
||
| 1486 | private function getUpdatedLanguageCodes(APIContentUpdateStruct $contentUpdateStruct) |
||
| 1502 | |||
| 1503 | /** |
||
| 1504 | * Returns all language codes used in given $fields. |
||
| 1505 | * |
||
| 1506 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value exists in initial language |
||
| 1507 | * |
||
| 1508 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
| 1509 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
| 1510 | * |
||
| 1511 | * @return array |
||
| 1512 | */ |
||
| 1513 | protected function getLanguageCodesForUpdate(APIContentUpdateStruct $contentUpdateStruct, APIContent $content) |
||
| 1525 | |||
| 1526 | /** |
||
| 1527 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode]. |
||
| 1528 | * |
||
| 1529 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType |
||
| 1530 | * or value is set for non-translatable field in language |
||
| 1531 | * other than main |
||
| 1532 | * |
||
| 1533 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct |
||
| 1534 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
| 1535 | * @param string $mainLanguageCode |
||
| 1536 | * |
||
| 1537 | * @return array |
||
| 1538 | */ |
||
| 1539 | protected function mapFieldsForUpdate( |
||
| 1577 | |||
| 1578 | /** |
||
| 1579 | * Publishes a content version. |
||
| 1580 | * |
||
| 1581 | * Publishes a content version and deletes archive versions if they overflow max archive versions. |
||
| 1582 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future. |
||
| 1583 | * |
||
| 1584 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1585 | * @param string[] $translations |
||
| 1586 | * |
||
| 1587 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 1588 | * |
||
| 1589 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 1590 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 1591 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1592 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1593 | */ |
||
| 1594 | public function publishVersion(APIVersionInfo $versionInfo, array $translations = Language::ALL) |
||
| 1632 | |||
| 1633 | /** |
||
| 1634 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1635 | * @param array $translations |
||
| 1636 | * |
||
| 1637 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
| 1638 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
||
| 1639 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
||
| 1640 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 1641 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1642 | */ |
||
| 1643 | protected function copyTranslationsFromPublishedVersion(APIVersionInfo $versionInfo, array $translations = []): void |
||
| 1737 | |||
| 1738 | /** |
||
| 1739 | * Publishes a content version. |
||
| 1740 | * |
||
| 1741 | * Publishes a content version and deletes archive versions if they overflow max archive versions. |
||
| 1742 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future. |
||
| 1743 | * |
||
| 1744 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 1745 | * |
||
| 1746 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1747 | * @param int|null $publicationDate If null existing date is kept if there is one, otherwise current time is used. |
||
| 1748 | * |
||
| 1749 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 1750 | */ |
||
| 1751 | protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicationDate = null) |
||
| 1803 | |||
| 1804 | /** |
||
| 1805 | * @return int |
||
| 1806 | */ |
||
| 1807 | protected function getUnixTimestamp() |
||
| 1811 | |||
| 1812 | /** |
||
| 1813 | * Removes the given version. |
||
| 1814 | * |
||
| 1815 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in |
||
| 1816 | * published state or is a last version of Content in non draft state |
||
| 1817 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version |
||
| 1818 | * |
||
| 1819 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1820 | */ |
||
| 1821 | public function deleteVersion(APIVersionInfo $versionInfo) |
||
| 1863 | |||
| 1864 | /** |
||
| 1865 | * Loads all versions for the given content. |
||
| 1866 | * |
||
| 1867 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions |
||
| 1868 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the given status is invalid |
||
| 1869 | * |
||
| 1870 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 1871 | * @param int|null $status |
||
| 1872 | * |
||
| 1873 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date |
||
| 1874 | */ |
||
| 1875 | public function loadVersions(ContentInfo $contentInfo, ?int $status = null) |
||
| 1904 | |||
| 1905 | /** |
||
| 1906 | * Copies the content to a new location. If no version is given, |
||
| 1907 | * all versions are copied, otherwise only the given version. |
||
| 1908 | * |
||
| 1909 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location |
||
| 1910 | * |
||
| 1911 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 1912 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to |
||
| 1913 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1914 | * |
||
| 1915 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 1916 | */ |
||
| 1917 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, APIVersionInfo $versionInfo = null) |
||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * Loads all outgoing relations for the given version. |
||
| 1975 | * |
||
| 1976 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
| 1977 | * |
||
| 1978 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
| 1979 | * |
||
| 1980 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
| 1981 | */ |
||
| 1982 | public function loadRelations(APIVersionInfo $versionInfo) |
||
| 1996 | |||
| 1997 | /** |
||
| 1998 | * Loads all outgoing relations for the given version without checking the permissions. |
||
| 1999 | * |
||
| 2000 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 2001 | * |
||
| 2002 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
| 2003 | */ |
||
| 2004 | protected function internalLoadRelations(APIVersionInfo $versionInfo): array |
||
| 2029 | |||
| 2030 | /** |
||
| 2031 | * {@inheritdoc} |
||
| 2032 | */ |
||
| 2033 | public function countReverseRelations(ContentInfo $contentInfo): int |
||
| 2043 | |||
| 2044 | /** |
||
| 2045 | * Loads all incoming relations for a content object. |
||
| 2046 | * |
||
| 2047 | * The relations come only from published versions of the source content objects |
||
| 2048 | * |
||
| 2049 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version |
||
| 2050 | * |
||
| 2051 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 2052 | * |
||
| 2053 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[] |
||
| 2054 | */ |
||
| 2055 | public function loadReverseRelations(ContentInfo $contentInfo) |
||
| 2081 | |||
| 2082 | /** |
||
| 2083 | * {@inheritdoc} |
||
| 2084 | */ |
||
| 2085 | public function loadReverseRelationList(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList |
||
| 2122 | |||
| 2123 | /** |
||
| 2124 | * Adds a relation of type common. |
||
| 2125 | * |
||
| 2126 | * The source of the relation is the content and version |
||
| 2127 | * referenced by $versionInfo. |
||
| 2128 | * |
||
| 2129 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version |
||
| 2130 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 2131 | * |
||
| 2132 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
| 2133 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation |
||
| 2134 | * |
||
| 2135 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation |
||
| 2136 | */ |
||
| 2137 | public function addRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
| 2178 | |||
| 2179 | /** |
||
| 2180 | * Removes a relation of type COMMON from a draft. |
||
| 2181 | * |
||
| 2182 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version |
||
| 2183 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft |
||
| 2184 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination |
||
| 2185 | * |
||
| 2186 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion |
||
| 2187 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent |
||
| 2188 | */ |
||
| 2189 | public function deleteRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent) |
||
| 2239 | |||
| 2240 | /** |
||
| 2241 | * {@inheritdoc} |
||
| 2242 | */ |
||
| 2243 | public function removeTranslation(ContentInfo $contentInfo, $languageCode) |
||
| 2251 | |||
| 2252 | /** |
||
| 2253 | * Delete Content item Translation from all Versions (including archived ones) of a Content Object. |
||
| 2254 | * |
||
| 2255 | * NOTE: this operation is risky and permanent, so user interface should provide a warning before performing it. |
||
| 2256 | * |
||
| 2257 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation |
||
| 2258 | * is the Main Translation of a Content Item. |
||
| 2259 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed |
||
| 2260 | * to delete the content (in one of the locations of the given Content Item). |
||
| 2261 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument |
||
| 2262 | * is invalid for the given content. |
||
| 2263 | * |
||
| 2264 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 2265 | * @param string $languageCode |
||
| 2266 | * |
||
| 2267 | * @since 6.13 |
||
| 2268 | */ |
||
| 2269 | public function deleteTranslation(ContentInfo $contentInfo, $languageCode) |
||
| 2346 | |||
| 2347 | /** |
||
| 2348 | * Delete specified Translation from a Content Draft. |
||
| 2349 | * |
||
| 2350 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation |
||
| 2351 | * is the only one the Content Draft has or it is the main Translation of a Content Object. |
||
| 2352 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed |
||
| 2353 | * to edit the Content (in one of the locations of the given Content Object). |
||
| 2354 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument |
||
| 2355 | * is invalid for the given Draft. |
||
| 2356 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if specified Version was not found |
||
| 2357 | * |
||
| 2358 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo Content Version Draft |
||
| 2359 | * @param string $languageCode Language code of the Translation to be removed |
||
| 2360 | * |
||
| 2361 | * @return \eZ\Publish\API\Repository\Values\Content\Content Content Draft w/o the specified Translation |
||
| 2362 | * |
||
| 2363 | * @since 6.12 |
||
| 2364 | */ |
||
| 2365 | public function deleteTranslationFromDraft(APIVersionInfo $versionInfo, $languageCode) |
||
| 2431 | |||
| 2432 | /** |
||
| 2433 | * Hides Content by making all the Locations appear hidden. |
||
| 2434 | * It does not persist hidden state on Location object itself. |
||
| 2435 | * |
||
| 2436 | * Content hidden by this API can be revealed by revealContent API. |
||
| 2437 | * |
||
| 2438 | * @see revealContent |
||
| 2439 | * |
||
| 2440 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 2441 | */ |
||
| 2442 | public function hideContent(ContentInfo $contentInfo): void |
||
| 2467 | |||
| 2468 | /** |
||
| 2469 | * Reveals Content hidden by hideContent API. |
||
| 2470 | * Locations which were hidden before hiding Content will remain hidden. |
||
| 2471 | * |
||
| 2472 | * @see hideContent |
||
| 2473 | * |
||
| 2474 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 2475 | */ |
||
| 2476 | public function revealContent(ContentInfo $contentInfo): void |
||
| 2501 | |||
| 2502 | /** |
||
| 2503 | * Instantiates a new content create struct object. |
||
| 2504 | * |
||
| 2505 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable |
||
| 2506 | * |
||
| 2507 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
| 2508 | * @param string $mainLanguageCode |
||
| 2509 | * |
||
| 2510 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct |
||
| 2511 | */ |
||
| 2512 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode) |
||
| 2522 | |||
| 2523 | /** |
||
| 2524 | * Instantiates a new content meta data update struct. |
||
| 2525 | * |
||
| 2526 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct |
||
| 2527 | */ |
||
| 2528 | public function newContentMetadataUpdateStruct() |
||
| 2532 | |||
| 2533 | /** |
||
| 2534 | * Instantiates a new content update struct. |
||
| 2535 | * |
||
| 2536 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct |
||
| 2537 | */ |
||
| 2538 | public function newContentUpdateStruct() |
||
| 2542 | |||
| 2543 | /** |
||
| 2544 | * @param \eZ\Publish\API\Repository\Values\User\User|null $user |
||
| 2545 | * |
||
| 2546 | * @return \eZ\Publish\API\Repository\Values\User\UserReference |
||
| 2547 | */ |
||
| 2548 | private function resolveUser(?User $user): UserReference |
||
| 2556 | } |
||
| 2557 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..