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  | 
            ||
| 59 | class ContentService implements ContentServiceInterface  | 
            ||
| 60 | { | 
            ||
| 61 | /** @var \eZ\Publish\Core\Repository\Repository */  | 
            ||
| 62 | protected $repository;  | 
            ||
| 63 | |||
| 64 | /** @var \eZ\Publish\SPI\Persistence\Handler */  | 
            ||
| 65 | protected $persistenceHandler;  | 
            ||
| 66 | |||
| 67 | /** @var array */  | 
            ||
| 68 | protected $settings;  | 
            ||
| 69 | |||
| 70 | /** @var \eZ\Publish\Core\Repository\Helper\DomainMapper */  | 
            ||
| 71 | protected $domainMapper;  | 
            ||
| 72 | |||
| 73 | /** @var \eZ\Publish\Core\Repository\Helper\RelationProcessor */  | 
            ||
| 74 | protected $relationProcessor;  | 
            ||
| 75 | |||
| 76 | /** @var \eZ\Publish\Core\Repository\Helper\NameSchemaService */  | 
            ||
| 77 | protected $nameSchemaService;  | 
            ||
| 78 | |||
| 79 | /** @var \eZ\Publish\Core\Repository\Helper\FieldTypeRegistry */  | 
            ||
| 80 | protected $fieldTypeRegistry;  | 
            ||
| 81 | |||
| 82 | /**  | 
            ||
| 83 | * Setups service with reference to repository object that created it & corresponding handler.  | 
            ||
| 84 | *  | 
            ||
| 85 | * @param \eZ\Publish\API\Repository\Repository $repository  | 
            ||
| 86 | * @param \eZ\Publish\SPI\Persistence\Handler $handler  | 
            ||
| 87 | * @param \eZ\Publish\Core\Repository\Helper\DomainMapper $domainMapper  | 
            ||
| 88 | * @param \eZ\Publish\Core\Repository\Helper\RelationProcessor $relationProcessor  | 
            ||
| 89 | * @param \eZ\Publish\Core\Repository\Helper\NameSchemaService $nameSchemaService  | 
            ||
| 90 | * @param \eZ\Publish\Core\Repository\Helper\FieldTypeRegistry $fieldTypeRegistry,  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 91 | * @param array $settings  | 
            ||
| 92 | */  | 
            ||
| 93 | public function __construct(  | 
            ||
| 94 | RepositoryInterface $repository,  | 
            ||
| 95 | Handler $handler,  | 
            ||
| 96 | Helper\DomainMapper $domainMapper,  | 
            ||
| 97 | Helper\RelationProcessor $relationProcessor,  | 
            ||
| 98 | Helper\NameSchemaService $nameSchemaService,  | 
            ||
| 99 | Helper\FieldTypeRegistry $fieldTypeRegistry,  | 
            ||
| 100 | array $settings = []  | 
            ||
| 101 |     ) { | 
            ||
| 102 | $this->repository = $repository;  | 
            ||
| 103 | $this->persistenceHandler = $handler;  | 
            ||
| 104 | $this->domainMapper = $domainMapper;  | 
            ||
| 105 | $this->relationProcessor = $relationProcessor;  | 
            ||
| 106 | $this->nameSchemaService = $nameSchemaService;  | 
            ||
| 107 | $this->fieldTypeRegistry = $fieldTypeRegistry;  | 
            ||
| 108 | // Union makes sure default settings are ignored if provided in argument  | 
            ||
| 109 | $this->settings = $settings + [  | 
            ||
| 110 | // Version archive limit (0-50), only enforced on publish, not on un-publish.  | 
            ||
| 111 | 'default_version_archive_limit' => 5,  | 
            ||
| 112 | ];  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | /**  | 
            ||
| 116 | * Loads a content info object.  | 
            ||
| 117 | *  | 
            ||
| 118 | * To load fields use loadContent  | 
            ||
| 119 | *  | 
            ||
| 120 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content  | 
            ||
| 121 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist  | 
            ||
| 122 | *  | 
            ||
| 123 | * @param int $contentId  | 
            ||
| 124 | *  | 
            ||
| 125 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo  | 
            ||
| 126 | */  | 
            ||
| 127 | public function loadContentInfo($contentId)  | 
            ||
| 128 |     { | 
            ||
| 129 | $contentInfo = $this->internalLoadContentInfo($contentId);  | 
            ||
| 130 |         if (!$this->repository->canUser('content', 'read', $contentInfo)) { | 
            ||
| 131 |             throw new UnauthorizedException('content', 'read', ['contentId' => $contentId]); | 
            ||
| 132 | }  | 
            ||
| 133 | |||
| 134 | return $contentInfo;  | 
            ||
| 135 | }  | 
            ||
| 136 | |||
| 137 | /**  | 
            ||
| 138 |      * {@inheritdoc} | 
            ||
| 139 | */  | 
            ||
| 140 | public function loadContentInfoList(array $contentIds): iterable  | 
            ||
| 141 |     { | 
            ||
| 142 | $contentInfoList = [];  | 
            ||
| 143 | $spiInfoList = $this->persistenceHandler->contentHandler()->loadContentInfoList($contentIds);  | 
            ||
| 144 |         foreach ($spiInfoList as $id => $spiInfo) { | 
            ||
| 145 | $contentInfo = $this->domainMapper->buildContentInfoDomainObject($spiInfo);  | 
            ||
| 146 |             if ($this->repository->canUser('content', 'read', $contentInfo)) { | 
            ||
| 147 | $contentInfoList[$id] = $contentInfo;  | 
            ||
| 148 | }  | 
            ||
| 149 | }  | 
            ||
| 150 | |||
| 151 | return $contentInfoList;  | 
            ||
| 152 | }  | 
            ||
| 153 | |||
| 154 | /**  | 
            ||
| 155 | * Loads a content info object.  | 
            ||
| 156 | *  | 
            ||
| 157 | * To load fields use loadContent  | 
            ||
| 158 | *  | 
            ||
| 159 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist  | 
            ||
| 160 | *  | 
            ||
| 161 | * @param mixed $id  | 
            ||
| 162 | * @param bool $isRemoteId  | 
            ||
| 163 | *  | 
            ||
| 164 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo  | 
            ||
| 165 | */  | 
            ||
| 166 | public function internalLoadContentInfo($id, $isRemoteId = false)  | 
            ||
| 167 |     { | 
            ||
| 168 |         try { | 
            ||
| 169 | $method = $isRemoteId ? 'loadContentInfoByRemoteId' : 'loadContentInfo';  | 
            ||
| 170 | |||
| 171 | return $this->domainMapper->buildContentInfoDomainObject(  | 
            ||
| 172 | $this->persistenceHandler->contentHandler()->$method($id)  | 
            ||
| 173 | );  | 
            ||
| 174 |         } catch (APINotFoundException $e) { | 
            ||
| 175 | throw new NotFoundException(  | 
            ||
| 176 | 'Content',  | 
            ||
| 177 | $id,  | 
            ||
| 178 | $e  | 
            ||
| 179 | );  | 
            ||
| 180 | }  | 
            ||
| 181 | }  | 
            ||
| 182 | |||
| 183 | /**  | 
            ||
| 184 | * Loads a content info object for the given remoteId.  | 
            ||
| 185 | *  | 
            ||
| 186 | * To load fields use loadContent  | 
            ||
| 187 | *  | 
            ||
| 188 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content  | 
            ||
| 189 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist  | 
            ||
| 190 | *  | 
            ||
| 191 | * @param string $remoteId  | 
            ||
| 192 | *  | 
            ||
| 193 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo  | 
            ||
| 194 | */  | 
            ||
| 195 | public function loadContentInfoByRemoteId($remoteId)  | 
            ||
| 196 |     { | 
            ||
| 197 | $contentInfo = $this->internalLoadContentInfo($remoteId, true);  | 
            ||
| 198 | |||
| 199 |         if (!$this->repository->canUser('content', 'read', $contentInfo)) { | 
            ||
| 200 |             throw new UnauthorizedException('content', 'read', ['remoteId' => $remoteId]); | 
            ||
| 201 | }  | 
            ||
| 202 | |||
| 203 | return $contentInfo;  | 
            ||
| 204 | }  | 
            ||
| 205 | |||
| 206 | /**  | 
            ||
| 207 | * Loads a version info of the given content object.  | 
            ||
| 208 | *  | 
            ||
| 209 | * If no version number is given, the method returns the current version  | 
            ||
| 210 | *  | 
            ||
| 211 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist  | 
            ||
| 212 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version  | 
            ||
| 213 | *  | 
            ||
| 214 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 215 | * @param int $versionNo the version number. If not given the current version is returned.  | 
            ||
| 216 | *  | 
            ||
| 217 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo  | 
            ||
| 218 | */  | 
            ||
| 219 | public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)  | 
            ||
| 220 |     { | 
            ||
| 221 | return $this->loadVersionInfoById($contentInfo->id, $versionNo);  | 
            ||
| 222 | }  | 
            ||
| 223 | |||
| 224 | /**  | 
            ||
| 225 | * Loads a version info of the given content object id.  | 
            ||
| 226 | *  | 
            ||
| 227 | * If no version number is given, the method returns the current version  | 
            ||
| 228 | *  | 
            ||
| 229 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist  | 
            ||
| 230 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version  | 
            ||
| 231 | *  | 
            ||
| 232 | * @param mixed $contentId  | 
            ||
| 233 | * @param int $versionNo the version number. If not given the current version is returned.  | 
            ||
| 234 | *  | 
            ||
| 235 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo  | 
            ||
| 236 | */  | 
            ||
| 237 | public function loadVersionInfoById($contentId, $versionNo = null)  | 
            ||
| 238 |     { | 
            ||
| 239 |         try { | 
            ||
| 240 | $spiVersionInfo = $this->persistenceHandler->contentHandler()->loadVersionInfo(  | 
            ||
| 241 | $contentId,  | 
            ||
| 242 | $versionNo  | 
            ||
| 243 | );  | 
            ||
| 244 |         } catch (APINotFoundException $e) { | 
            ||
| 245 | throw new NotFoundException(  | 
            ||
| 246 | 'VersionInfo',  | 
            ||
| 247 | [  | 
            ||
| 248 | 'contentId' => $contentId,  | 
            ||
| 249 | 'versionNo' => $versionNo,  | 
            ||
| 250 | ],  | 
            ||
| 251 | $e  | 
            ||
| 252 | );  | 
            ||
| 253 | }  | 
            ||
| 254 | |||
| 255 | $versionInfo = $this->domainMapper->buildVersionInfoDomainObject($spiVersionInfo);  | 
            ||
| 256 | |||
| 257 |         if ($versionInfo->isPublished()) { | 
            ||
| 258 | $function = 'read';  | 
            ||
| 259 |         } else { | 
            ||
| 260 | $function = 'versionread';  | 
            ||
| 261 | }  | 
            ||
| 262 | |||
| 263 |         if (!$this->repository->canUser('content', $function, $versionInfo)) { | 
            ||
| 264 |             throw new UnauthorizedException('content', $function, ['contentId' => $contentId]); | 
            ||
| 265 | }  | 
            ||
| 266 | |||
| 267 | return $versionInfo;  | 
            ||
| 268 | }  | 
            ||
| 269 | |||
| 270 | /**  | 
            ||
| 271 |      * {@inheritdoc} | 
            ||
| 272 | */  | 
            ||
| 273 | public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)  | 
            ||
| 274 |     { | 
            ||
| 275 | // Change $useAlwaysAvailable to false to avoid contentInfo lookup if we know alwaysAvailable is disabled  | 
            ||
| 276 |         if ($useAlwaysAvailable && !$contentInfo->alwaysAvailable) { | 
            ||
| 277 | $useAlwaysAvailable = false;  | 
            ||
| 278 | }  | 
            ||
| 279 | |||
| 280 | return $this->loadContent(  | 
            ||
| 281 | $contentInfo->id,  | 
            ||
| 282 | $languages,  | 
            ||
| 283 | $versionNo,// On purpose pass as-is and not use $contentInfo, to make sure to return actual current version on null  | 
            ||
| 284 | $useAlwaysAvailable  | 
            ||
| 285 | );  | 
            ||
| 286 | }  | 
            ||
| 287 | |||
| 288 | /**  | 
            ||
| 289 |      * {@inheritdoc} | 
            ||
| 290 | */  | 
            ||
| 291 | public function loadContentByVersionInfo(APIVersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true)  | 
            ||
| 305 | |||
| 306 | /**  | 
            ||
| 307 |      * {@inheritdoc} | 
            ||
| 308 | */  | 
            ||
| 309 | public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)  | 
            ||
| 310 |     { | 
            ||
| 311 | $content = $this->internalLoadContent($contentId, $languages, $versionNo, false, $useAlwaysAvailable);  | 
            ||
| 312 | |||
| 313 |         if (!$this->repository->canUser('content', 'read', $content)) { | 
            ||
| 314 |             throw new UnauthorizedException('content', 'read', ['contentId' => $contentId]); | 
            ||
| 315 | }  | 
            ||
| 316 | if (  | 
            ||
| 317 | !$content->getVersionInfo()->isPublished()  | 
            ||
| 318 |             && !$this->repository->canUser('content', 'versionread', $content) | 
            ||
| 319 |         ) { | 
            ||
| 320 |             throw new UnauthorizedException('content', 'versionread', ['contentId' => $contentId, 'versionNo' => $versionNo]); | 
            ||
| 321 | }  | 
            ||
| 322 | |||
| 323 | return $content;  | 
            ||
| 324 | }  | 
            ||
| 325 | |||
| 326 | /**  | 
            ||
| 327 | * Loads content in a version of the given content object.  | 
            ||
| 328 | *  | 
            ||
| 329 | * If no version number is given, the method returns the current version  | 
            ||
| 330 | *  | 
            ||
| 331 | * @internal  | 
            ||
| 332 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist  | 
            ||
| 333 | *  | 
            ||
| 334 | * @param mixed $id  | 
            ||
| 335 | * @param array|null $languages A language priority, filters returned fields and is used as prioritized language code on  | 
            ||
| 336 | * returned value object. If not given all languages are returned.  | 
            ||
| 337 | * @param int|null $versionNo the version number. If not given the current version is returned  | 
            ||
| 338 | * @param bool $isRemoteId  | 
            ||
| 339 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true  | 
            ||
| 340 | *  | 
            ||
| 341 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 342 | */  | 
            ||
| 343 | public function internalLoadContent($id, array $languages = null, $versionNo = null, $isRemoteId = false, $useAlwaysAvailable = true)  | 
            ||
| 344 |     { | 
            ||
| 345 |         try { | 
            ||
| 346 | // Get Content ID if lookup by remote ID  | 
            ||
| 347 |             if ($isRemoteId) { | 
            ||
| 348 | $spiContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($id);  | 
            ||
| 349 | $id = $spiContentInfo->id;  | 
            ||
| 350 | // Set $isRemoteId to false as the next loads will be for content id now that we have it (for exception use now)  | 
            ||
| 351 | $isRemoteId = false;  | 
            ||
| 352 | }  | 
            ||
| 353 | |||
| 354 | $loadLanguages = $languages;  | 
            ||
| 355 | $alwaysAvailableLanguageCode = null;  | 
            ||
| 356 | // Set main language on $languages filter if not empty (all) and $useAlwaysAvailable being true  | 
            ||
| 357 | // @todo Move use always available logic to SPI load methods, like done in location handler in 7.x  | 
            ||
| 358 |             if (!empty($loadLanguages) && $useAlwaysAvailable) { | 
            ||
| 359 |                 if (!isset($spiContentInfo)) { | 
            ||
| 360 | $spiContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($id);  | 
            ||
| 361 | }  | 
            ||
| 362 | |||
| 363 |                 if ($spiContentInfo->alwaysAvailable) { | 
            ||
| 364 | $loadLanguages[] = $alwaysAvailableLanguageCode = $spiContentInfo->mainLanguageCode;  | 
            ||
| 365 | $loadLanguages = array_unique($loadLanguages);  | 
            ||
| 366 | }  | 
            ||
| 367 | }  | 
            ||
| 368 | |||
| 369 | $spiContent = $this->persistenceHandler->contentHandler()->load(  | 
            ||
| 370 | $id,  | 
            ||
| 371 | $versionNo,  | 
            ||
| 372 | $loadLanguages  | 
            ||
| 373 | );  | 
            ||
| 374 |         } catch (APINotFoundException $e) { | 
            ||
| 375 | throw new NotFoundException(  | 
            ||
| 376 | 'Content',  | 
            ||
| 377 | [  | 
            ||
| 378 | $isRemoteId ? 'remoteId' : 'id' => $id,  | 
            ||
| 379 | 'languages' => $languages,  | 
            ||
| 380 | 'versionNo' => $versionNo,  | 
            ||
| 381 | ],  | 
            ||
| 382 | $e  | 
            ||
| 383 | );  | 
            ||
| 384 | }  | 
            ||
| 385 | |||
| 386 |         if ($languages === null) { | 
            ||
| 387 | $languages = [];  | 
            ||
| 388 | }  | 
            ||
| 389 | |||
| 390 | return $this->domainMapper->buildContentDomainObject(  | 
            ||
| 391 | $spiContent,  | 
            ||
| 392 | $this->repository->getContentTypeService()->loadContentType(  | 
            ||
| 393 | $spiContent->versionInfo->contentInfo->contentTypeId,  | 
            ||
| 394 | $languages  | 
            ||
| 395 | ),  | 
            ||
| 396 | $languages,  | 
            ||
| 397 | $alwaysAvailableLanguageCode  | 
            ||
| 398 | );  | 
            ||
| 399 | }  | 
            ||
| 400 | |||
| 401 | /**  | 
            ||
| 402 | * Loads content in a version for the content object reference by the given remote id.  | 
            ||
| 403 | *  | 
            ||
| 404 | * If no version is given, the method returns the current version  | 
            ||
| 405 | *  | 
            ||
| 406 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist  | 
            ||
| 407 | * @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  | 
            ||
| 408 | *  | 
            ||
| 409 | * @param string $remoteId  | 
            ||
| 410 | * @param array $languages A language filter for fields. If not given all languages are returned  | 
            ||
| 411 | * @param int $versionNo the version number. If not given the current version is returned  | 
            ||
| 412 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true  | 
            ||
| 413 | *  | 
            ||
| 414 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 415 | */  | 
            ||
| 416 | public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)  | 
            ||
| 417 |     { | 
            ||
| 418 | $content = $this->internalLoadContent($remoteId, $languages, $versionNo, true, $useAlwaysAvailable);  | 
            ||
| 419 | |||
| 420 |         if (!$this->repository->canUser('content', 'read', $content)) { | 
            ||
| 421 |             throw new UnauthorizedException('content', 'read', ['remoteId' => $remoteId]); | 
            ||
| 422 | }  | 
            ||
| 423 | |||
| 424 | if (  | 
            ||
| 425 | !$content->getVersionInfo()->isPublished()  | 
            ||
| 426 |             && !$this->repository->canUser('content', 'versionread', $content) | 
            ||
| 427 |         ) { | 
            ||
| 428 |             throw new UnauthorizedException('content', 'versionread', ['remoteId' => $remoteId, 'versionNo' => $versionNo]); | 
            ||
| 429 | }  | 
            ||
| 430 | |||
| 431 | return $content;  | 
            ||
| 432 | }  | 
            ||
| 433 | |||
| 434 | /**  | 
            ||
| 435 | * Bulk-load Content items by the list of ContentInfo Value Objects.  | 
            ||
| 436 | *  | 
            ||
| 437 | * Note: it does not throw exceptions on load, just ignores erroneous Content item.  | 
            ||
| 438 | * Moreover, since the method works on pre-loaded ContentInfo list, it is assumed that user is  | 
            ||
| 439 | * allowed to access every Content on the list.  | 
            ||
| 440 | *  | 
            ||
| 441 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList  | 
            ||
| 442 | * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on  | 
            ||
| 443 | * returned value object. If not given all languages are returned.  | 
            ||
| 444 | * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,  | 
            ||
| 445 | * unless all languages have been asked for.  | 
            ||
| 446 | *  | 
            ||
| 447 | * @return \eZ\Publish\API\Repository\Values\Content\Content[] list of Content items with Content Ids as keys  | 
            ||
| 448 | */  | 
            ||
| 449 | public function loadContentListByContentInfo(  | 
            ||
| 450 | array $contentInfoList,  | 
            ||
| 451 | array $languages = [],  | 
            ||
| 452 | $useAlwaysAvailable = true  | 
            ||
| 453 |     ) { | 
            ||
| 454 | $loadAllLanguages = $languages === Language::ALL;  | 
            ||
| 455 | $contentIds = [];  | 
            ||
| 456 | $contentTypeIds = [];  | 
            ||
| 457 | $translations = $languages;  | 
            ||
| 458 |         foreach ($contentInfoList as $contentInfo) { | 
            ||
| 459 | $contentIds[] = $contentInfo->id;  | 
            ||
| 460 | $contentTypeIds[] = $contentInfo->contentTypeId;  | 
            ||
| 461 | // Unless we are told to load all languages, we add main language to translations so they are loaded too  | 
            ||
| 462 | // Might in some case load more languages then intended, but prioritised handling will pick right one  | 
            ||
| 463 |             if (!$loadAllLanguages && $useAlwaysAvailable && $contentInfo->alwaysAvailable) { | 
            ||
| 464 | $translations[] = $contentInfo->mainLanguageCode;  | 
            ||
| 465 | }  | 
            ||
| 466 | }  | 
            ||
| 467 | |||
| 468 | $contentList = [];  | 
            ||
| 469 | $translations = array_unique($translations);  | 
            ||
| 470 | $spiContentList = $this->persistenceHandler->contentHandler()->loadContentList(  | 
            ||
| 471 | $contentIds,  | 
            ||
| 472 | $translations  | 
            ||
| 473 | );  | 
            ||
| 474 | $contentTypeList = $this->repository->getContentTypeService()->loadContentTypeList(  | 
            ||
| 475 | array_unique($contentTypeIds),  | 
            ||
| 476 | $languages  | 
            ||
| 477 | );  | 
            ||
| 478 |         foreach ($spiContentList as $contentId => $spiContent) { | 
            ||
| 479 | $contentInfo = $spiContent->versionInfo->contentInfo;  | 
            ||
| 480 | $contentList[$contentId] = $this->domainMapper->buildContentDomainObject(  | 
            ||
| 481 | $spiContent,  | 
            ||
| 482 | $contentTypeList[$contentInfo->contentTypeId],  | 
            ||
| 483 | $languages,  | 
            ||
| 484 | $contentInfo->alwaysAvailable ? $contentInfo->mainLanguageCode : null  | 
            ||
| 485 | );  | 
            ||
| 486 | }  | 
            ||
| 487 | |||
| 488 | return $contentList;  | 
            ||
| 489 | }  | 
            ||
| 490 | |||
| 491 | /**  | 
            ||
| 492 | * Creates a new content draft assigned to the authenticated user.  | 
            ||
| 493 | *  | 
            ||
| 494 | * If a different userId is given in $contentCreateStruct it is assigned to the given user  | 
            ||
| 495 | * but this required special rights for the authenticated user  | 
            ||
| 496 | * (this is useful for content staging where the transfer process does not  | 
            ||
| 497 | * have to authenticate with the user which created the content object in the source server).  | 
            ||
| 498 | * The user has to publish the draft if it should be visible.  | 
            ||
| 499 | * In 4.x at least one location has to be provided in the location creation array.  | 
            ||
| 500 | *  | 
            ||
| 501 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location  | 
            ||
| 502 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the provided remoteId exists in the system, required properties on  | 
            ||
| 503 | * struct are missing or invalid, or if multiple locations are under the  | 
            ||
| 504 | * same parent.  | 
            ||
| 505 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid,  | 
            ||
| 506 | * or if a required field is missing / set to an empty value.  | 
            ||
| 507 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType,  | 
            ||
| 508 | * or value is set for non-translatable field in language  | 
            ||
| 509 | * other than main.  | 
            ||
| 510 | *  | 
            ||
| 511 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct  | 
            ||
| 512 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content  | 
            ||
| 513 | *  | 
            ||
| 514 | * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft  | 
            ||
| 515 | */  | 
            ||
| 516 | public function createContent(APIContentCreateStruct $contentCreateStruct, array $locationCreateStructs = [])  | 
            ||
| 517 |     { | 
            ||
| 518 |         if ($contentCreateStruct->mainLanguageCode === null) { | 
            ||
| 519 |             throw new InvalidArgumentException('$contentCreateStruct', "'mainLanguageCode' property must be set"); | 
            ||
| 520 | }  | 
            ||
| 521 | |||
| 522 |         if ($contentCreateStruct->contentType === null) { | 
            ||
| 523 |             throw new InvalidArgumentException('$contentCreateStruct', "'contentType' property must be set"); | 
            ||
| 524 | }  | 
            ||
| 525 | |||
| 526 | $contentCreateStruct = clone $contentCreateStruct;  | 
            ||
| 527 | |||
| 528 |         if ($contentCreateStruct->ownerId === null) { | 
            ||
| 529 | $contentCreateStruct->ownerId = $this->repository->getCurrentUserReference()->getUserId();  | 
            ||
| 530 | }  | 
            ||
| 531 | |||
| 532 |         if ($contentCreateStruct->alwaysAvailable === null) { | 
            ||
| 533 | $contentCreateStruct->alwaysAvailable = $contentCreateStruct->contentType->defaultAlwaysAvailable ?: false;  | 
            ||
| 534 | }  | 
            ||
| 535 | |||
| 536 | $contentCreateStruct->contentType = $this->repository->getContentTypeService()->loadContentType(  | 
            ||
| 537 | $contentCreateStruct->contentType->id  | 
            ||
| 538 | );  | 
            ||
| 539 | |||
| 540 |         if (empty($contentCreateStruct->sectionId)) { | 
            ||
| 541 |             if (isset($locationCreateStructs[0])) { | 
            ||
| 542 | $location = $this->repository->getLocationService()->loadLocation(  | 
            ||
| 543 | $locationCreateStructs[0]->parentLocationId  | 
            ||
| 544 | );  | 
            ||
| 545 | $contentCreateStruct->sectionId = $location->contentInfo->sectionId;  | 
            ||
| 546 |             } else { | 
            ||
| 547 | $contentCreateStruct->sectionId = 1;  | 
            ||
| 548 | }  | 
            ||
| 549 | }  | 
            ||
| 550 | |||
| 551 |         if (!$this->repository->canUser('content', 'create', $contentCreateStruct, $locationCreateStructs)) { | 
            ||
| 552 | throw new UnauthorizedException(  | 
            ||
| 553 | 'content',  | 
            ||
| 554 | 'create',  | 
            ||
| 555 | [  | 
            ||
| 556 | 'parentLocationId' => isset($locationCreateStructs[0]) ?  | 
            ||
| 557 | $locationCreateStructs[0]->parentLocationId :  | 
            ||
| 558 | null,  | 
            ||
| 559 | 'sectionId' => $contentCreateStruct->sectionId,  | 
            ||
| 560 | ]  | 
            ||
| 561 | );  | 
            ||
| 562 | }  | 
            ||
| 563 | |||
| 564 |         if (!empty($contentCreateStruct->remoteId)) { | 
            ||
| 565 |             try { | 
            ||
| 566 | $this->loadContentByRemoteId($contentCreateStruct->remoteId);  | 
            ||
| 567 | |||
| 568 | throw new InvalidArgumentException(  | 
            ||
| 569 | '$contentCreateStruct',  | 
            ||
| 570 |                     "Another content with remoteId '{$contentCreateStruct->remoteId}' exists" | 
            ||
| 571 | );  | 
            ||
| 572 |             } catch (APINotFoundException $e) { | 
            ||
| 573 | // Do nothing  | 
            ||
| 574 | }  | 
            ||
| 575 |         } else { | 
            ||
| 576 | $contentCreateStruct->remoteId = $this->domainMapper->getUniqueHash($contentCreateStruct);  | 
            ||
| 577 | }  | 
            ||
| 578 | |||
| 579 | $spiLocationCreateStructs = $this->buildSPILocationCreateStructs($locationCreateStructs);  | 
            ||
| 580 | |||
| 581 | $languageCodes = $this->getLanguageCodesForCreate($contentCreateStruct);  | 
            ||
| 582 | $fields = $this->mapFieldsForCreate($contentCreateStruct);  | 
            ||
| 583 | |||
| 584 | $fieldValues = [];  | 
            ||
| 585 | $spiFields = [];  | 
            ||
| 586 | $allFieldErrors = [];  | 
            ||
| 587 | $inputRelations = [];  | 
            ||
| 588 | $locationIdToContentIdMapping = [];  | 
            ||
| 589 | |||
| 590 |         foreach ($contentCreateStruct->contentType->getFieldDefinitions() as $fieldDefinition) { | 
            ||
| 591 | /** @var $fieldType \eZ\Publish\Core\FieldType\FieldType */  | 
            ||
| 592 | $fieldType = $this->fieldTypeRegistry->getFieldType(  | 
            ||
| 593 | $fieldDefinition->fieldTypeIdentifier  | 
            ||
| 594 | );  | 
            ||
| 595 | |||
| 596 |             foreach ($languageCodes as $languageCode) { | 
            ||
| 597 | $isEmptyValue = false;  | 
            ||
| 598 | $valueLanguageCode = $fieldDefinition->isTranslatable ? $languageCode : $contentCreateStruct->mainLanguageCode;  | 
            ||
| 599 | $isLanguageMain = $languageCode === $contentCreateStruct->mainLanguageCode;  | 
            ||
| 600 |                 if (isset($fields[$fieldDefinition->identifier][$valueLanguageCode])) { | 
            ||
| 601 | $fieldValue = $fields[$fieldDefinition->identifier][$valueLanguageCode]->value;  | 
            ||
| 602 |                 } else { | 
            ||
| 603 | $fieldValue = $fieldDefinition->defaultValue;  | 
            ||
| 604 | }  | 
            ||
| 605 | |||
| 606 | $fieldValue = $fieldType->acceptValue($fieldValue);  | 
            ||
| 607 | |||
| 608 |                 if ($fieldType->isEmptyValue($fieldValue)) { | 
            ||
| 609 | $isEmptyValue = true;  | 
            ||
| 610 |                     if ($fieldDefinition->isRequired) { | 
            ||
| 611 | $allFieldErrors[$fieldDefinition->id][$languageCode] = new ValidationError(  | 
            ||
| 612 | "Value for required field definition '%identifier%' with language '%languageCode%' is empty",  | 
            ||
| 613 | null,  | 
            ||
| 614 | ['%identifier%' => $fieldDefinition->identifier, '%languageCode%' => $languageCode],  | 
            ||
| 615 | 'empty'  | 
            ||
| 616 | );  | 
            ||
| 617 | }  | 
            ||
| 618 |                 } else { | 
            ||
| 619 | $fieldErrors = $fieldType->validate(  | 
            ||
| 620 | $fieldDefinition,  | 
            ||
| 621 | $fieldValue  | 
            ||
| 622 | );  | 
            ||
| 623 |                     if (!empty($fieldErrors)) { | 
            ||
| 624 | $allFieldErrors[$fieldDefinition->id][$languageCode] = $fieldErrors;  | 
            ||
| 625 | }  | 
            ||
| 626 | }  | 
            ||
| 627 | |||
| 628 |                 if (!empty($allFieldErrors)) { | 
            ||
| 629 | continue;  | 
            ||
| 630 | }  | 
            ||
| 631 | |||
| 632 | $this->relationProcessor->appendFieldRelations(  | 
            ||
| 633 | $inputRelations,  | 
            ||
| 634 | $locationIdToContentIdMapping,  | 
            ||
| 635 | $fieldType,  | 
            ||
| 636 | $fieldValue,  | 
            ||
| 637 | $fieldDefinition->id  | 
            ||
| 638 | );  | 
            ||
| 639 | $fieldValues[$fieldDefinition->identifier][$languageCode] = $fieldValue;  | 
            ||
| 640 | |||
| 641 | // Only non-empty value for: translatable field or in main language  | 
            ||
| 642 | if (  | 
            ||
| 643 | (!$isEmptyValue && $fieldDefinition->isTranslatable) ||  | 
            ||
| 644 | (!$isEmptyValue && $isLanguageMain)  | 
            ||
| 645 |                 ) { | 
            ||
| 646 | $spiFields[] = new SPIField(  | 
            ||
| 647 | [  | 
            ||
| 648 | 'id' => null,  | 
            ||
| 649 | 'fieldDefinitionId' => $fieldDefinition->id,  | 
            ||
| 650 | 'type' => $fieldDefinition->fieldTypeIdentifier,  | 
            ||
| 651 | 'value' => $fieldType->toPersistenceValue($fieldValue),  | 
            ||
| 652 | 'languageCode' => $languageCode,  | 
            ||
| 653 | 'versionNo' => null,  | 
            ||
| 654 | ]  | 
            ||
| 655 | );  | 
            ||
| 656 | }  | 
            ||
| 657 | }  | 
            ||
| 658 | }  | 
            ||
| 659 | |||
| 660 |         if (!empty($allFieldErrors)) { | 
            ||
| 661 | throw new ContentFieldValidationException($allFieldErrors);  | 
            ||
| 662 | }  | 
            ||
| 663 | |||
| 664 | $spiContentCreateStruct = new SPIContentCreateStruct(  | 
            ||
| 665 | [  | 
            ||
| 666 | 'name' => $this->nameSchemaService->resolve(  | 
            ||
| 667 | $contentCreateStruct->contentType->nameSchema,  | 
            ||
| 668 | $contentCreateStruct->contentType,  | 
            ||
| 669 | $fieldValues,  | 
            ||
| 670 | $languageCodes  | 
            ||
| 671 | ),  | 
            ||
| 672 | 'typeId' => $contentCreateStruct->contentType->id,  | 
            ||
| 673 | 'sectionId' => $contentCreateStruct->sectionId,  | 
            ||
| 674 | 'ownerId' => $contentCreateStruct->ownerId,  | 
            ||
| 675 | 'locations' => $spiLocationCreateStructs,  | 
            ||
| 676 | 'fields' => $spiFields,  | 
            ||
| 677 | 'alwaysAvailable' => $contentCreateStruct->alwaysAvailable,  | 
            ||
| 678 | 'remoteId' => $contentCreateStruct->remoteId,  | 
            ||
| 679 | 'modified' => isset($contentCreateStruct->modificationDate) ? $contentCreateStruct->modificationDate->getTimestamp() : time(),  | 
            ||
| 680 | 'initialLanguageId' => $this->persistenceHandler->contentLanguageHandler()->loadByLanguageCode(  | 
            ||
| 681 | $contentCreateStruct->mainLanguageCode  | 
            ||
| 682 | )->id,  | 
            ||
| 683 | ]  | 
            ||
| 684 | );  | 
            ||
| 685 | |||
| 686 | $defaultObjectStates = $this->getDefaultObjectStates();  | 
            ||
| 687 | |||
| 688 | $this->repository->beginTransaction();  | 
            ||
| 689 |         try { | 
            ||
| 690 | $spiContent = $this->persistenceHandler->contentHandler()->create($spiContentCreateStruct);  | 
            ||
| 691 | $this->relationProcessor->processFieldRelations(  | 
            ||
| 692 | $inputRelations,  | 
            ||
| 693 | $spiContent->versionInfo->contentInfo->id,  | 
            ||
| 694 | $spiContent->versionInfo->versionNo,  | 
            ||
| 695 | $contentCreateStruct->contentType  | 
            ||
| 696 | );  | 
            ||
| 697 | |||
| 698 | $objectStateHandler = $this->persistenceHandler->objectStateHandler();  | 
            ||
| 699 |             foreach ($defaultObjectStates as $objectStateGroupId => $objectState) { | 
            ||
| 700 | $objectStateHandler->setContentState(  | 
            ||
| 701 | $spiContent->versionInfo->contentInfo->id,  | 
            ||
| 702 | $objectStateGroupId,  | 
            ||
| 703 | $objectState->id  | 
            ||
| 704 | );  | 
            ||
| 705 | }  | 
            ||
| 706 | |||
| 707 | $this->repository->commit();  | 
            ||
| 708 |         } catch (Exception $e) { | 
            ||
| 709 | $this->repository->rollback();  | 
            ||
| 710 | throw $e;  | 
            ||
| 711 | }  | 
            ||
| 712 | |||
| 713 | return $this->domainMapper->buildContentDomainObject(  | 
            ||
| 714 | $spiContent,  | 
            ||
| 715 | $contentCreateStruct->contentType  | 
            ||
| 716 | );  | 
            ||
| 717 | }  | 
            ||
| 718 | |||
| 719 | /**  | 
            ||
| 720 | * Returns an array of default content states with content state group id as key.  | 
            ||
| 721 | *  | 
            ||
| 722 | * @return \eZ\Publish\SPI\Persistence\Content\ObjectState[]  | 
            ||
| 723 | */  | 
            ||
| 724 | protected function getDefaultObjectStates()  | 
            ||
| 739 | |||
| 740 | /**  | 
            ||
| 741 | * Returns all language codes used in given $fields.  | 
            ||
| 742 | *  | 
            ||
| 743 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value is set in main language  | 
            ||
| 744 | *  | 
            ||
| 745 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct  | 
            ||
| 746 | *  | 
            ||
| 747 | * @return string[]  | 
            ||
| 748 | */  | 
            ||
| 749 | protected function getLanguageCodesForCreate(APIContentCreateStruct $contentCreateStruct)  | 
            ||
| 773 | |||
| 774 | /**  | 
            ||
| 775 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode].  | 
            ||
| 776 | *  | 
            ||
| 777 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType  | 
            ||
| 778 | * or value is set for non-translatable field in language  | 
            ||
| 779 | * other than main  | 
            ||
| 780 | *  | 
            ||
| 781 | * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct  | 
            ||
| 782 | *  | 
            ||
| 783 | * @return array  | 
            ||
| 784 | */  | 
            ||
| 785 | protected function mapFieldsForCreate(APIContentCreateStruct $contentCreateStruct)  | 
            ||
| 786 |     { | 
            ||
| 787 | $fields = [];  | 
            ||
| 788 | |||
| 789 |         foreach ($contentCreateStruct->fields as $field) { | 
            ||
| 790 | $fieldDefinition = $contentCreateStruct->contentType->getFieldDefinition($field->fieldDefIdentifier);  | 
            ||
| 791 | |||
| 792 |             if ($fieldDefinition === null) { | 
            ||
| 793 | throw new ContentValidationException(  | 
            ||
| 794 | "Field definition '%identifier%' does not exist in given ContentType",  | 
            ||
| 795 | ['%identifier%' => $field->fieldDefIdentifier]  | 
            ||
| 796 | );  | 
            ||
| 797 | }  | 
            ||
| 798 | |||
| 799 |             if ($field->languageCode === null) { | 
            ||
| 800 | $field = $this->cloneField(  | 
            ||
| 801 | $field,  | 
            ||
| 802 | ['languageCode' => $contentCreateStruct->mainLanguageCode]  | 
            ||
| 803 | );  | 
            ||
| 804 | }  | 
            ||
| 805 | |||
| 806 |             if (!$fieldDefinition->isTranslatable && ($field->languageCode != $contentCreateStruct->mainLanguageCode)) { | 
            ||
| 807 | throw new ContentValidationException(  | 
            ||
| 808 | "A value is set for non translatable field definition '%identifier%' with language '%languageCode%'",  | 
            ||
| 809 | ['%identifier%' => $field->fieldDefIdentifier, '%languageCode%' => $field->languageCode]  | 
            ||
| 810 | );  | 
            ||
| 811 | }  | 
            ||
| 812 | |||
| 813 | $fields[$field->fieldDefIdentifier][$field->languageCode] = $field;  | 
            ||
| 814 | }  | 
            ||
| 815 | |||
| 816 | return $fields;  | 
            ||
| 817 | }  | 
            ||
| 818 | |||
| 819 | /**  | 
            ||
| 820 | * Clones $field with overriding specific properties from given $overrides array.  | 
            ||
| 821 | *  | 
            ||
| 822 | * @param Field $field  | 
            ||
| 823 | * @param array $overrides  | 
            ||
| 824 | *  | 
            ||
| 825 | * @return Field  | 
            ||
| 826 | */  | 
            ||
| 827 | private function cloneField(Field $field, array $overrides = [])  | 
            ||
| 842 | |||
| 843 | /**  | 
            ||
| 844 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 845 | *  | 
            ||
| 846 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs  | 
            ||
| 847 | *  | 
            ||
| 848 | * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct[]  | 
            ||
| 849 | */  | 
            ||
| 850 | protected function buildSPILocationCreateStructs(array $locationCreateStructs)  | 
            ||
| 892 | |||
| 893 | /**  | 
            ||
| 894 | * Updates the metadata.  | 
            ||
| 895 | *  | 
            ||
| 896 |      * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent | 
            ||
| 897 | *  | 
            ||
| 898 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data  | 
            ||
| 899 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists  | 
            ||
| 900 | *  | 
            ||
| 901 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 902 | * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct  | 
            ||
| 903 | *  | 
            ||
| 904 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes  | 
            ||
| 905 | */  | 
            ||
| 906 | public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)  | 
            ||
| 993 | |||
| 994 | /**  | 
            ||
| 995 | * Publishes URL aliases for all locations of a given content.  | 
            ||
| 996 | *  | 
            ||
| 997 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 998 | * @param bool $updatePathIdentificationString this parameter is legacy storage specific for updating  | 
            ||
| 999 | * ezcontentobject_tree.path_identification_string, it is ignored by other storage engines  | 
            ||
| 1000 | */  | 
            ||
| 1001 | protected function publishUrlAliasesForContent(APIContent $content, $updatePathIdentificationString = true)  | 
            ||
| 1027 | |||
| 1028 | /**  | 
            ||
| 1029 | * Deletes a content object including all its versions and locations including their subtrees.  | 
            ||
| 1030 | *  | 
            ||
| 1031 | * @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)  | 
            ||
| 1032 | *  | 
            ||
| 1033 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 1034 | *  | 
            ||
| 1035 | * @return mixed[] Affected Location Id's  | 
            ||
| 1036 | */  | 
            ||
| 1037 | public function deleteContent(ContentInfo $contentInfo)  | 
            ||
| 1064 | |||
| 1065 | /**  | 
            ||
| 1066 | * Creates a draft from a published or archived version.  | 
            ||
| 1067 | *  | 
            ||
| 1068 | * If no version is given, the current published version is used.  | 
            ||
| 1069 | * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.  | 
            ||
| 1070 | * It can be changed on updating the version.  | 
            ||
| 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 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException  | 
            ||
| 1079 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the current-user is not allowed to create the draft  | 
            ||
| 1080 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to create the draft  | 
            ||
| 1081 | */  | 
            ||
| 1082 | public function createContentDraft(ContentInfo $contentInfo, APIVersionInfo $versionInfo = null, User $creator = null)  | 
            ||
| 1162 | |||
| 1163 | /**  | 
            ||
| 1164 |      * {@inheritdoc} | 
            ||
| 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 | /**  | 
            ||
| 1215 |      * {@inheritdoc} | 
            ||
| 1216 | */  | 
            ||
| 1217 | public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList  | 
            ||
| 1249 | |||
| 1250 | /**  | 
            ||
| 1251 | * Updates the fields of a draft.  | 
            ||
| 1252 | *  | 
            ||
| 1253 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1254 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct  | 
            ||
| 1255 | *  | 
            ||
| 1256 | * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields  | 
            ||
| 1257 | *  | 
            ||
| 1258 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid,  | 
            ||
| 1259 | * or if a required field is missing / set to an empty value.  | 
            ||
| 1260 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType,  | 
            ||
| 1261 | * or value is set for non-translatable field in language  | 
            ||
| 1262 | * other than main.  | 
            ||
| 1263 | *  | 
            ||
| 1264 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version  | 
            ||
| 1265 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 1266 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a property on the struct is invalid.  | 
            ||
| 1267 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 1268 | */  | 
            ||
| 1269 | public function updateContent(APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct)  | 
            ||
| 1296 | |||
| 1297 | /**  | 
            ||
| 1298 | * Updates the fields of a draft without checking the permissions.  | 
            ||
| 1299 | *  | 
            ||
| 1300 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid,  | 
            ||
| 1301 | * or if a required field is missing / set to an empty value.  | 
            ||
| 1302 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType,  | 
            ||
| 1303 | * or value is set for non-translatable field in language  | 
            ||
| 1304 | * other than main.  | 
            ||
| 1305 | *  | 
            ||
| 1306 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 1307 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a property on the struct is invalid.  | 
            ||
| 1308 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 1309 | */  | 
            ||
| 1310 | protected function internalUpdateContent(APIVersionInfo $versionInfo, APIContentUpdateStruct $contentUpdateStruct): Content  | 
            ||
| 1481 | |||
| 1482 | /**  | 
            ||
| 1483 | * Returns only updated language codes.  | 
            ||
| 1484 | *  | 
            ||
| 1485 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct  | 
            ||
| 1486 | *  | 
            ||
| 1487 | * @return array  | 
            ||
| 1488 | */  | 
            ||
| 1489 | private function getUpdatedLanguageCodes(APIContentUpdateStruct $contentUpdateStruct)  | 
            ||
| 1505 | |||
| 1506 | /**  | 
            ||
| 1507 | * Returns all language codes used in given $fields.  | 
            ||
| 1508 | *  | 
            ||
| 1509 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if no field value exists in initial language  | 
            ||
| 1510 | *  | 
            ||
| 1511 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct  | 
            ||
| 1512 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content  | 
            ||
| 1513 | *  | 
            ||
| 1514 | * @return array  | 
            ||
| 1515 | */  | 
            ||
| 1516 | protected function getLanguageCodesForUpdate(APIContentUpdateStruct $contentUpdateStruct, APIContent $content)  | 
            ||
| 1528 | |||
| 1529 | /**  | 
            ||
| 1530 | * Returns an array of fields like $fields[$field->fieldDefIdentifier][$field->languageCode].  | 
            ||
| 1531 | *  | 
            ||
| 1532 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException If field definition does not exist in the ContentType  | 
            ||
| 1533 | * or value is set for non-translatable field in language  | 
            ||
| 1534 | * other than main  | 
            ||
| 1535 | *  | 
            ||
| 1536 | * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct  | 
            ||
| 1537 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType  | 
            ||
| 1538 | * @param string $mainLanguageCode  | 
            ||
| 1539 | *  | 
            ||
| 1540 | * @return array  | 
            ||
| 1541 | */  | 
            ||
| 1542 | protected function mapFieldsForUpdate(  | 
            ||
| 1580 | |||
| 1581 | /**  | 
            ||
| 1582 | * Publishes a content version.  | 
            ||
| 1583 | *  | 
            ||
| 1584 | * Publishes a content version and deletes archive versions if they overflow max archive versions.  | 
            ||
| 1585 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future.  | 
            ||
| 1586 | *  | 
            ||
| 1587 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1588 | * @param string[] $translations  | 
            ||
| 1589 | *  | 
            ||
| 1590 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1591 | *  | 
            ||
| 1592 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 1593 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 1594 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 1595 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 1596 | */  | 
            ||
| 1597 | public function publishVersion(APIVersionInfo $versionInfo, array $translations = Language::ALL)  | 
            ||
| 1640 | |||
| 1641 | /**  | 
            ||
| 1642 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1643 | * @param array $translations  | 
            ||
| 1644 | *  | 
            ||
| 1645 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException  | 
            ||
| 1646 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException  | 
            ||
| 1647 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException  | 
            ||
| 1648 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException  | 
            ||
| 1649 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException  | 
            ||
| 1650 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException  | 
            ||
| 1651 | */  | 
            ||
| 1652 | protected function copyTranslationsFromPublishedVersion(APIVersionInfo $versionInfo, array $translations = []): void  | 
            ||
| 1701 | |||
| 1702 | /**  | 
            ||
| 1703 | * Publishes a content version.  | 
            ||
| 1704 | *  | 
            ||
| 1705 | * Publishes a content version and deletes archive versions if they overflow max archive versions.  | 
            ||
| 1706 | * Max archive versions are currently a configuration, but might be moved to be a param of ContentType in the future.  | 
            ||
| 1707 | *  | 
            ||
| 1708 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 1709 | *  | 
            ||
| 1710 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1711 | * @param int|null $publicationDate If null existing date is kept if there is one, otherwise current time is used.  | 
            ||
| 1712 | *  | 
            ||
| 1713 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1714 | */  | 
            ||
| 1715 | protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicationDate = null)  | 
            ||
| 1767 | |||
| 1768 | /**  | 
            ||
| 1769 | * @return int  | 
            ||
| 1770 | */  | 
            ||
| 1771 | protected function getUnixTimestamp()  | 
            ||
| 1775 | |||
| 1776 | /**  | 
            ||
| 1777 | * Removes the given version.  | 
            ||
| 1778 | *  | 
            ||
| 1779 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in  | 
            ||
| 1780 | * published state or is a last version of Content in non draft state  | 
            ||
| 1781 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version  | 
            ||
| 1782 | *  | 
            ||
| 1783 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1784 | */  | 
            ||
| 1785 | public function deleteVersion(APIVersionInfo $versionInfo)  | 
            ||
| 1827 | |||
| 1828 | /**  | 
            ||
| 1829 | * Loads all versions for the given content.  | 
            ||
| 1830 | *  | 
            ||
| 1831 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions  | 
            ||
| 1832 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the given status is invalid  | 
            ||
| 1833 | *  | 
            ||
| 1834 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 1835 | * @param int|null $status  | 
            ||
| 1836 | *  | 
            ||
| 1837 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date  | 
            ||
| 1838 | */  | 
            ||
| 1839 | public function loadVersions(ContentInfo $contentInfo, ?int $status = null)  | 
            ||
| 1868 | |||
| 1869 | /**  | 
            ||
| 1870 | * Copies the content to a new location. If no version is given,  | 
            ||
| 1871 | * all versions are copied, otherwise only the given version.  | 
            ||
| 1872 | *  | 
            ||
| 1873 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location  | 
            ||
| 1874 | *  | 
            ||
| 1875 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 1876 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to  | 
            ||
| 1877 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1878 | *  | 
            ||
| 1879 | * @return \eZ\Publish\API\Repository\Values\Content\Content  | 
            ||
| 1880 | */  | 
            ||
| 1881 | public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, APIVersionInfo $versionInfo = null)  | 
            ||
| 1936 | |||
| 1937 | /**  | 
            ||
| 1938 | * Loads all outgoing relations for the given version.  | 
            ||
| 1939 | *  | 
            ||
| 1940 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version  | 
            ||
| 1941 | *  | 
            ||
| 1942 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo  | 
            ||
| 1943 | *  | 
            ||
| 1944 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[]  | 
            ||
| 1945 | */  | 
            ||
| 1946 | public function loadRelations(APIVersionInfo $versionInfo)  | 
            ||
| 1960 | |||
| 1961 | /**  | 
            ||
| 1962 | * Loads all outgoing relations for the given version without checking the permissions.  | 
            ||
| 1963 | *  | 
            ||
| 1964 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version  | 
            ||
| 1965 | *  | 
            ||
| 1966 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[]  | 
            ||
| 1967 | */  | 
            ||
| 1968 | protected function internalLoadRelations(APIVersionInfo $versionInfo): array  | 
            ||
| 1993 | |||
| 1994 | /**  | 
            ||
| 1995 |      * {@inheritdoc} | 
            ||
| 1996 | */  | 
            ||
| 1997 | public function countReverseRelations(ContentInfo $contentInfo): int  | 
            ||
| 2007 | |||
| 2008 | /**  | 
            ||
| 2009 | * Loads all incoming relations for a content object.  | 
            ||
| 2010 | *  | 
            ||
| 2011 | * The relations come only from published versions of the source content objects  | 
            ||
| 2012 | *  | 
            ||
| 2013 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version  | 
            ||
| 2014 | *  | 
            ||
| 2015 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 2016 | *  | 
            ||
| 2017 | * @return \eZ\Publish\API\Repository\Values\Content\Relation[]  | 
            ||
| 2018 | */  | 
            ||
| 2019 | public function loadReverseRelations(ContentInfo $contentInfo)  | 
            ||
| 2045 | |||
| 2046 | /**  | 
            ||
| 2047 |      * {@inheritdoc} | 
            ||
| 2048 | */  | 
            ||
| 2049 | public function loadReverseRelationList(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList  | 
            ||
| 2086 | |||
| 2087 | /**  | 
            ||
| 2088 | * Adds a relation of type common.  | 
            ||
| 2089 | *  | 
            ||
| 2090 | * The source of the relation is the content and version  | 
            ||
| 2091 | * referenced by $versionInfo.  | 
            ||
| 2092 | *  | 
            ||
| 2093 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version  | 
            ||
| 2094 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 2095 | *  | 
            ||
| 2096 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion  | 
            ||
| 2097 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation  | 
            ||
| 2098 | *  | 
            ||
| 2099 | * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation  | 
            ||
| 2100 | */  | 
            ||
| 2101 | public function addRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent)  | 
            ||
| 2142 | |||
| 2143 | /**  | 
            ||
| 2144 | * Removes a relation of type COMMON from a draft.  | 
            ||
| 2145 | *  | 
            ||
| 2146 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version  | 
            ||
| 2147 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft  | 
            ||
| 2148 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination  | 
            ||
| 2149 | *  | 
            ||
| 2150 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion  | 
            ||
| 2151 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent  | 
            ||
| 2152 | */  | 
            ||
| 2153 | public function deleteRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent)  | 
            ||
| 2203 | |||
| 2204 | /**  | 
            ||
| 2205 |      * {@inheritdoc} | 
            ||
| 2206 | */  | 
            ||
| 2207 | public function removeTranslation(ContentInfo $contentInfo, $languageCode)  | 
            ||
| 2215 | |||
| 2216 | /**  | 
            ||
| 2217 | * Delete Content item Translation from all Versions (including archived ones) of a Content Object.  | 
            ||
| 2218 | *  | 
            ||
| 2219 | * NOTE: this operation is risky and permanent, so user interface should provide a warning before performing it.  | 
            ||
| 2220 | *  | 
            ||
| 2221 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation  | 
            ||
| 2222 | * is the Main Translation of a Content Item.  | 
            ||
| 2223 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed  | 
            ||
| 2224 | * to delete the content (in one of the locations of the given Content Item).  | 
            ||
| 2225 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument  | 
            ||
| 2226 | * is invalid for the given content.  | 
            ||
| 2227 | *  | 
            ||
| 2228 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 2229 | * @param string $languageCode  | 
            ||
| 2230 | *  | 
            ||
| 2231 | * @since 6.13  | 
            ||
| 2232 | */  | 
            ||
| 2233 | public function deleteTranslation(ContentInfo $contentInfo, $languageCode)  | 
            ||
| 2310 | |||
| 2311 | /**  | 
            ||
| 2312 | * Delete specified Translation from a Content Draft.  | 
            ||
| 2313 | *  | 
            ||
| 2314 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation  | 
            ||
| 2315 | * is the only one the Content Draft has or it is the main Translation of a Content Object.  | 
            ||
| 2316 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed  | 
            ||
| 2317 | * to edit the Content (in one of the locations of the given Content Object).  | 
            ||
| 2318 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument  | 
            ||
| 2319 | * is invalid for the given Draft.  | 
            ||
| 2320 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if specified Version was not found  | 
            ||
| 2321 | *  | 
            ||
| 2322 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo Content Version Draft  | 
            ||
| 2323 | * @param string $languageCode Language code of the Translation to be removed  | 
            ||
| 2324 | *  | 
            ||
| 2325 | * @return \eZ\Publish\API\Repository\Values\Content\Content Content Draft w/o the specified Translation  | 
            ||
| 2326 | *  | 
            ||
| 2327 | * @since 6.12  | 
            ||
| 2328 | */  | 
            ||
| 2329 | public function deleteTranslationFromDraft(APIVersionInfo $versionInfo, $languageCode)  | 
            ||
| 2395 | |||
| 2396 | /**  | 
            ||
| 2397 | * Hides Content by making all the Locations appear hidden.  | 
            ||
| 2398 | * It does not persist hidden state on Location object itself.  | 
            ||
| 2399 | *  | 
            ||
| 2400 | * Content hidden by this API can be revealed by revealContent API.  | 
            ||
| 2401 | *  | 
            ||
| 2402 | * @see revealContent  | 
            ||
| 2403 | *  | 
            ||
| 2404 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 2405 | */  | 
            ||
| 2406 | public function hideContent(ContentInfo $contentInfo): void  | 
            ||
| 2431 | |||
| 2432 | /**  | 
            ||
| 2433 | * Reveals Content hidden by hideContent API.  | 
            ||
| 2434 | * Locations which were hidden before hiding Content will remain hidden.  | 
            ||
| 2435 | *  | 
            ||
| 2436 | * @see hideContent  | 
            ||
| 2437 | *  | 
            ||
| 2438 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo  | 
            ||
| 2439 | */  | 
            ||
| 2440 | public function revealContent(ContentInfo $contentInfo): void  | 
            ||
| 2465 | |||
| 2466 | /**  | 
            ||
| 2467 | * Instantiates a new content create struct object.  | 
            ||
| 2468 | *  | 
            ||
| 2469 | * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable  | 
            ||
| 2470 | *  | 
            ||
| 2471 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType  | 
            ||
| 2472 | * @param string $mainLanguageCode  | 
            ||
| 2473 | *  | 
            ||
| 2474 | * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct  | 
            ||
| 2475 | */  | 
            ||
| 2476 | public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)  | 
            ||
| 2486 | |||
| 2487 | /**  | 
            ||
| 2488 | * Instantiates a new content meta data update struct.  | 
            ||
| 2489 | *  | 
            ||
| 2490 | * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct  | 
            ||
| 2491 | */  | 
            ||
| 2492 | public function newContentMetadataUpdateStruct()  | 
            ||
| 2496 | |||
| 2497 | /**  | 
            ||
| 2498 | * Instantiates a new content update struct.  | 
            ||
| 2499 | *  | 
            ||
| 2500 | * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct  | 
            ||
| 2501 | */  | 
            ||
| 2502 | public function newContentUpdateStruct()  | 
            ||
| 2506 | |||
| 2507 | /**  | 
            ||
| 2508 | * @param \eZ\Publish\API\Repository\Values\User\User|null $user  | 
            ||
| 2509 | *  | 
            ||
| 2510 | * @return \eZ\Publish\API\Repository\Values\User\UserReference  | 
            ||
| 2511 | */  | 
            ||
| 2512 | private function resolveUser(?User $user): UserReference  | 
            ||
| 2520 | }  | 
            ||
| 2521 | 
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
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.