vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/SignalSlot/ContentService.php line 201

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) eZ Systems AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. namespace eZ\Publish\Core\SignalSlot;
  7. use eZ\Publish\API\Repository\ContentService as ContentServiceInterface;
  8. use eZ\Publish\API\Repository\Values\Content\ContentDraftList;
  9. use eZ\Publish\API\Repository\Values\Content\ContentCreateStruct;
  10. use eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct;
  11. use eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct;
  12. use eZ\Publish\API\Repository\Values\Content\Language;
  13. use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
  14. use eZ\Publish\API\Repository\Values\Content\ContentInfo;
  15. use eZ\Publish\API\Repository\Values\Content\RelationList;
  16. use eZ\Publish\API\Repository\Values\Content\VersionInfo;
  17. use eZ\Publish\API\Repository\Values\ContentType\ContentType;
  18. use eZ\Publish\API\Repository\Values\User\User;
  19. use eZ\Publish\Core\SignalSlot\Signal\ContentService\CreateContentSignal;
  20. use eZ\Publish\Core\SignalSlot\Signal\ContentService\DeleteTranslationSignal;
  21. use eZ\Publish\Core\SignalSlot\Signal\ContentService\HideContentSignal;
  22. use eZ\Publish\Core\SignalSlot\Signal\ContentService\RemoveTranslationSignal;
  23. use eZ\Publish\Core\SignalSlot\Signal\ContentService\RevealContentSignal;
  24. use eZ\Publish\Core\SignalSlot\Signal\ContentService\UpdateContentMetadataSignal;
  25. use eZ\Publish\Core\SignalSlot\Signal\ContentService\DeleteContentSignal;
  26. use eZ\Publish\Core\SignalSlot\Signal\ContentService\CreateContentDraftSignal;
  27. use eZ\Publish\Core\SignalSlot\Signal\ContentService\UpdateContentSignal;
  28. use eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal;
  29. use eZ\Publish\Core\SignalSlot\Signal\ContentService\DeleteVersionSignal;
  30. use eZ\Publish\Core\SignalSlot\Signal\ContentService\CopyContentSignal;
  31. use eZ\Publish\Core\SignalSlot\Signal\ContentService\AddRelationSignal;
  32. use eZ\Publish\Core\SignalSlot\Signal\ContentService\DeleteRelationSignal;
  33. /**
  34.  * ContentService class.
  35.  */
  36. class ContentService implements ContentServiceInterface
  37. {
  38.     /**
  39.      * Aggregated service.
  40.      *
  41.      * @var \eZ\Publish\API\Repository\ContentService
  42.      */
  43.     protected $service;
  44.     /**
  45.      * SignalDispatcher.
  46.      *
  47.      * @var \eZ\Publish\Core\SignalSlot\SignalDispatcher
  48.      */
  49.     protected $signalDispatcher;
  50.     /**
  51.      * Constructor.
  52.      *
  53.      * Construct service object from aggregated service and signal
  54.      * dispatcher
  55.      *
  56.      * @param \eZ\Publish\API\Repository\ContentService $service
  57.      * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
  58.      */
  59.     public function __construct(ContentServiceInterface $serviceSignalDispatcher $signalDispatcher)
  60.     {
  61.         $this->service $service;
  62.         $this->signalDispatcher $signalDispatcher;
  63.     }
  64.     /**
  65.      * Loads a content info object.
  66.      *
  67.      * To load fields use loadContent
  68.      *
  69.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
  70.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist
  71.      *
  72.      * @param int $contentId
  73.      *
  74.      * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
  75.      */
  76.     public function loadContentInfo($contentId)
  77.     {
  78.         return $this->service->loadContentInfo($contentId);
  79.     }
  80.     /**
  81.      * {@inheritdoc}
  82.      */
  83.     public function loadContentInfoList(array $contentIds): iterable
  84.     {
  85.         return $this->service->loadContentInfoList($contentIds);
  86.     }
  87.     /**
  88.      * Loads a content info object for the given remoteId.
  89.      *
  90.      * To load fields use loadContent
  91.      *
  92.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
  93.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist
  94.      *
  95.      * @param string $remoteId
  96.      *
  97.      * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
  98.      */
  99.     public function loadContentInfoByRemoteId($remoteId)
  100.     {
  101.         return $this->service->loadContentInfoByRemoteId($remoteId);
  102.     }
  103.     /**
  104.      * Loads a version info of the given content object.
  105.      *
  106.      * If no version number is given, the method returns the current version
  107.      *
  108.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
  109.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  110.      *
  111.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  112.      * @param int $versionNo the version number. If not given the current version is returned.
  113.      *
  114.      * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
  115.      */
  116.     public function loadVersionInfo(ContentInfo $contentInfo$versionNo null)
  117.     {
  118.         return $this->service->loadVersionInfo($contentInfo$versionNo);
  119.     }
  120.     /**
  121.      * Loads a version info of the given content object id.
  122.      *
  123.      * If no version number is given, the method returns the current version
  124.      *
  125.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
  126.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  127.      *
  128.      * @param mixed $contentId
  129.      * @param int $versionNo the version number. If not given the current version is returned.
  130.      *
  131.      * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
  132.      */
  133.     public function loadVersionInfoById($contentId$versionNo null)
  134.     {
  135.         return $this->service->loadVersionInfoById($contentId$versionNo);
  136.     }
  137.     /**
  138.      * Loads content in a version for the given content info object.
  139.      *
  140.      * If no version number is given, the method returns the current version
  141.      *
  142.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
  143.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  144.      *
  145.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  146.      * @param array $languages A language filter for fields. If not given all languages are returned
  147.      * @param int $versionNo the version number. If not given the current version is returned
  148.      * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
  149.      *
  150.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  151.      */
  152.     public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages null$versionNo null$useAlwaysAvailable true)
  153.     {
  154.         return $this->service->loadContentByContentInfo($contentInfo$languages$versionNo$useAlwaysAvailable);
  155.     }
  156.     /**
  157.      * Loads content in the version given by version info.
  158.      *
  159.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  160.      *
  161.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  162.      * @param array $languages A language filter for fields. If not given all languages are returned
  163.      * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
  164.      *
  165.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  166.      */
  167.     public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages null$useAlwaysAvailable true)
  168.     {
  169.         return $this->service->loadContentByVersionInfo($versionInfo$languages$useAlwaysAvailable);
  170.     }
  171.     /**
  172.      * Loads content in a version of the given content object.
  173.      *
  174.      * If no version number is given, the method returns the current version
  175.      *
  176.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist
  177.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  178.      *
  179.      * @param int $contentId
  180.      * @param array $languages A language filter for fields. If not given all languages are returned
  181.      * @param int $versionNo the version number. If not given the current version is returned
  182.      * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
  183.      *
  184.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  185.      */
  186.     public function loadContent($contentId, array $languages null$versionNo null$useAlwaysAvailable true)
  187.     {
  188.         return $this->service->loadContent($contentId$languages$versionNo$useAlwaysAvailable);
  189.     }
  190.     /**
  191.      * Loads content in a version for the content object reference by the given remote id.
  192.      *
  193.      * If no version is given, the method returns the current version
  194.      *
  195.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist
  196.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  197.      *
  198.      * @param string $remoteId
  199.      * @param array $languages A language filter for fields. If not given all languages are returned
  200.      * @param int $versionNo the version number. If not given the current version is returned
  201.      * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
  202.      *
  203.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  204.      */
  205.     public function loadContentByRemoteId($remoteId, array $languages null$versionNo null$useAlwaysAvailable true)
  206.     {
  207.         return $this->service->loadContentByRemoteId($remoteId$languages$versionNo$useAlwaysAvailable);
  208.     }
  209.     /**
  210.      * Creates a new content draft assigned to the authenticated user.
  211.      *
  212.      * If a different userId is given in $contentCreateStruct it is assigned to the given user
  213.      * but this required special rights for the authenticated user
  214.      * (this is useful for content staging where the transfer process does not
  215.      * have to authenticate with the user which created the content object in the source server).
  216.      * The user has to publish the draft if it should be visible.
  217.      * In 4.x at least one location has to be provided in the location creation array.
  218.      *
  219.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
  220.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system
  221.      *                                                                        or there is no location provided (4.x) or multiple locations
  222.      *                                                                        are under the same parent or if the a field value is not accepted by the field type
  223.      * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid
  224.      * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing or is set to an empty value
  225.      *
  226.      * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct
  227.      * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content
  228.      *
  229.      * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
  230.      */
  231.     public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = [])
  232.     {
  233.         $returnValue $this->service->createContent($contentCreateStruct$locationCreateStructs);
  234.         $this->signalDispatcher->emit(
  235.             new CreateContentSignal(
  236.                 [
  237.                     'contentId' => $returnValue->getVersionInfo()->getContentInfo()->id,
  238.                     'versionNo' => $returnValue->getVersionInfo()->versionNo,
  239.                 ]
  240.             )
  241.         );
  242.         return $returnValue;
  243.     }
  244.     /**
  245.      * Updates the metadata.
  246.      *
  247.      * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent
  248.      *
  249.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data
  250.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists
  251.      *
  252.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  253.      * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct
  254.      *
  255.      * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes
  256.      */
  257.     public function updateContentMetadata(ContentInfo $contentInfoContentMetadataUpdateStruct $contentMetadataUpdateStruct)
  258.     {
  259.         $returnValue $this->service->updateContentMetadata($contentInfo$contentMetadataUpdateStruct);
  260.         $this->signalDispatcher->emit(
  261.             new UpdateContentMetadataSignal(
  262.                 [
  263.                     'contentId' => $contentInfo->id,
  264.                 ]
  265.             )
  266.         );
  267.         return $returnValue;
  268.     }
  269.     /**
  270.      * Deletes a content object including all its versions and locations including their subtrees.
  271.      *
  272.      * @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)
  273.      *
  274.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  275.      *
  276.      * @return mixed[] Affected Location Id's
  277.      */
  278.     public function deleteContent(ContentInfo $contentInfo)
  279.     {
  280.         $returnValue $this->service->deleteContent($contentInfo);
  281.         $this->signalDispatcher->emit(
  282.             new DeleteContentSignal(
  283.                 [
  284.                     'contentId' => $contentInfo->id,
  285.                     'affectedLocationIds' => $returnValue,
  286.                 ]
  287.             )
  288.         );
  289.         return $returnValue;
  290.     }
  291.     /**
  292.      * Creates a draft from a published or archived version.
  293.      *
  294.      * If no version is given, the current published version is used.
  295.      * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.
  296.      * It can be changed on updating the version.
  297.      *
  298.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft
  299.      *
  300.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  301.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  302.      * @param \eZ\Publish\API\Repository\Values\User\User $user if set given user is used to create the draft - otherwise the current user is used
  303.      * @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.
  304.      *
  305.      * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
  306.      */
  307.     public function createContentDraft(
  308.         ContentInfo $contentInfo,
  309.         VersionInfo $versionInfo null,
  310.         User $creator null,
  311.         ?Language $language null
  312.     ) {
  313.         $contentDraft $this->service->createContentDraft($contentInfo$versionInfo$creator$language);
  314.         $this->signalDispatcher->emit(
  315.             new CreateContentDraftSignal(
  316.                 [
  317.                     'contentId' => $contentInfo->id,
  318.                     'versionNo' => ($versionInfo !== null $versionInfo->versionNo null),
  319.                     'newVersionNo' => $contentDraft->getVersionInfo()->versionNo,
  320.                     'userId' => ($creator !== null $creator->id null),
  321.                     'languageCode' => $contentDraft->getVersionInfo()->initialLanguageCode,
  322.                 ]
  323.             )
  324.         );
  325.         return $contentDraft;
  326.     }
  327.     /**
  328.      * Counts drafts for a user.
  329.      *
  330.      * If no user is given the number of drafts for the authenticated user are returned
  331.      *
  332.      * @param \eZ\Publish\API\Repository\Values\User\User|null $user The user to load drafts for, if defined, otherwise drafts for current-user
  333.      *
  334.      * @return int The number of drafts ({@link VersionInfo}) owned by the given user
  335.      */
  336.     public function countContentDrafts(?User $user null): int
  337.     {
  338.         return $this->service->countContentDrafts($user);
  339.     }
  340.     /**
  341.      * Loads drafts for a user.
  342.      *
  343.      * If no user is given the drafts for the authenticated user are returned
  344.      *
  345.      * @param \eZ\Publish\API\Repository\Values\User\User $user
  346.      *
  347.      * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] the drafts ({@link VersionInfo}) owned by the given user
  348.      *
  349.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list
  350.      */
  351.     public function loadContentDrafts(User $user null)
  352.     {
  353.         return $this->service->loadContentDrafts($user);
  354.     }
  355.     /**
  356.      * {@inheritdoc}
  357.      */
  358.     public function loadContentDraftList(?User $user nullint $offset 0int $limit = -1): ContentDraftList
  359.     {
  360.         return $this->service->loadContentDraftList($user$offset$limit);
  361.     }
  362.     /**
  363.      * Updates the fields of a draft.
  364.      *
  365.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
  366.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
  367.      * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid
  368.      * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
  369.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type
  370.      *
  371.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  372.      * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct
  373.      *
  374.      * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields
  375.      */
  376.     public function updateContent(VersionInfo $versionInfoContentUpdateStruct $contentUpdateStruct)
  377.     {
  378.         $returnValue $this->service->updateContent($versionInfo$contentUpdateStruct);
  379.         $this->signalDispatcher->emit(
  380.             new UpdateContentSignal(
  381.                 [
  382.                     'contentId' => $versionInfo->getContentInfo()->id,
  383.                     'versionNo' => $versionInfo->versionNo,
  384.                 ]
  385.             )
  386.         );
  387.         return $returnValue;
  388.     }
  389.     /**
  390.      * Publishes a content version.
  391.      *
  392.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
  393.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
  394.      *
  395.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  396.      * @param string[] $translations
  397.      *
  398.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  399.      */
  400.     public function publishVersion(VersionInfo $versionInfo, array $translations Language::ALL)
  401.     {
  402.         $returnValue $this->service->publishVersion($versionInfo$translations);
  403.         $this->signalDispatcher->emit(
  404.             new PublishVersionSignal(
  405.                 [
  406.                     'contentId' => $versionInfo->getContentInfo()->id,
  407.                     'versionNo' => $versionInfo->versionNo,
  408.                     'affectedTranslations' => $translations,
  409.                 ]
  410.             )
  411.         );
  412.         return $returnValue;
  413.     }
  414.     /**
  415.      * Removes the given version.
  416.      *
  417.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
  418.      *         published state or is the last version of the Content
  419.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
  420.      *
  421.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  422.      */
  423.     public function deleteVersion(VersionInfo $versionInfo)
  424.     {
  425.         $returnValue $this->service->deleteVersion($versionInfo);
  426.         $this->signalDispatcher->emit(
  427.             new DeleteVersionSignal(
  428.                 [
  429.                     'contentId' => $versionInfo->contentInfo->id,
  430.                     'versionNo' => $versionInfo->versionNo,
  431.                 ]
  432.             )
  433.         );
  434.         return $returnValue;
  435.     }
  436.     /**
  437.      * Loads all versions for the given content.
  438.      *
  439.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
  440.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the given status is invalid
  441.      *
  442.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  443.      * @param int|null $status
  444.      *
  445.      * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date
  446.      */
  447.     public function loadVersions(ContentInfo $contentInfo, ?int $status null)
  448.     {
  449.         return $this->service->loadVersions($contentInfo$status);
  450.     }
  451.     /**
  452.      * Copies the content to a new location. If no version is given,
  453.      * all versions are copied, otherwise only the given version.
  454.      *
  455.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
  456.      *
  457.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  458.      * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
  459.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  460.      *
  461.      * @return \eZ\Publish\API\Repository\Values\Content\Content
  462.      */
  463.     public function copyContent(ContentInfo $contentInfoLocationCreateStruct $destinationLocationCreateStructVersionInfo $versionInfo null)
  464.     {
  465.         $returnValue $this->service->copyContent($contentInfo$destinationLocationCreateStruct$versionInfo);
  466.         $this->signalDispatcher->emit(
  467.             new CopyContentSignal(
  468.                 [
  469.                     'srcContentId' => $contentInfo->id,
  470.                     'srcVersionNo' => ($versionInfo !== null $versionInfo->versionNo null),
  471.                     'dstContentId' => $returnValue->getVersionInfo()->getContentInfo()->id,
  472.                     'dstVersionNo' => $returnValue->getVersionInfo()->versionNo,
  473.                     'dstParentLocationId' => $destinationLocationCreateStruct->parentLocationId,
  474.                 ]
  475.             )
  476.         );
  477.         return $returnValue;
  478.     }
  479.     /**
  480.      * Loads all outgoing relations for the given version.
  481.      *
  482.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
  483.      *
  484.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  485.      *
  486.      * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
  487.      */
  488.     public function loadRelations(VersionInfo $versionInfo)
  489.     {
  490.         return $this->service->loadRelations($versionInfo);
  491.     }
  492.     /**
  493.      * {@inheritdoc}
  494.      */
  495.     public function countReverseRelations(ContentInfo $contentInfo): int
  496.     {
  497.         return $this->service->countReverseRelations($contentInfo);
  498.     }
  499.     /**
  500.      * Loads all incoming relations for a content object.
  501.      *
  502.      * The relations come only from published versions of the source content objects
  503.      *
  504.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
  505.      *
  506.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  507.      *
  508.      * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
  509.      */
  510.     public function loadReverseRelations(ContentInfo $contentInfo)
  511.     {
  512.         return $this->service->loadReverseRelations($contentInfo);
  513.     }
  514.     /**
  515.      * {@inheritdoc}
  516.      */
  517.     public function loadReverseRelationList(ContentInfo $contentInfoint $offset 0int $limit = -1): RelationList
  518.     {
  519.         return $this->service->loadReverseRelationList($contentInfo$offset$limit);
  520.     }
  521.     /**
  522.      * Adds a relation of type common.
  523.      *
  524.      * The source of the relation is the content and version
  525.      * referenced by $versionInfo.
  526.      *
  527.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
  528.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
  529.      *
  530.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
  531.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
  532.      *
  533.      * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation
  534.      */
  535.     public function addRelation(VersionInfo $sourceVersionContentInfo $destinationContent)
  536.     {
  537.         $returnValue $this->service->addRelation($sourceVersion$destinationContent);
  538.         $this->signalDispatcher->emit(
  539.             new AddRelationSignal(
  540.                 [
  541.                     'srcContentId' => $sourceVersion->contentInfo->id,
  542.                     'srcVersionNo' => $sourceVersion->versionNo,
  543.                     'dstContentId' => $destinationContent->id,
  544.                 ]
  545.             )
  546.         );
  547.         return $returnValue;
  548.     }
  549.     /**
  550.      * Removes a relation of type COMMON from a draft.
  551.      *
  552.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
  553.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
  554.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
  555.      *
  556.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
  557.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
  558.      */
  559.     public function deleteRelation(VersionInfo $sourceVersionContentInfo $destinationContent)
  560.     {
  561.         $returnValue $this->service->deleteRelation($sourceVersion$destinationContent);
  562.         $this->signalDispatcher->emit(
  563.             new DeleteRelationSignal(
  564.                 [
  565.                     'srcContentId' => $sourceVersion->contentInfo->id,
  566.                     'srcVersionNo' => $sourceVersion->versionNo,
  567.                     'dstContentId' => $destinationContent->id,
  568.                 ]
  569.             )
  570.         );
  571.         return $returnValue;
  572.     }
  573.     /**
  574.      * {@inheritdoc}
  575.      */
  576.     public function removeTranslation(ContentInfo $contentInfo$languageCode)
  577.     {
  578.         @trigger_error(
  579.             __METHOD__ ' is deprecated, use deleteTranslation instead',
  580.             E_USER_DEPRECATED
  581.         );
  582.         $this->deleteTranslation($contentInfo$languageCode);
  583.     }
  584.     /**
  585.      * Delete Content item Translation from all Versions (including archived ones) of a Content Object.
  586.      *
  587.      * NOTE: this operation is risky and permanent, so user interface should provide a warning before performing it.
  588.      *
  589.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation
  590.      *         is the Main Translation of a Content Item.
  591.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed
  592.      *         to delete the content (in one of the locations of the given Content Item).
  593.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument
  594.      *         is invalid for the given content.
  595.      *
  596.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  597.      * @param string $languageCode
  598.      *
  599.      * @since 6.13
  600.      */
  601.     public function deleteTranslation(ContentInfo $contentInfo$languageCode)
  602.     {
  603.         $this->service->deleteTranslation($contentInfo$languageCode);
  604.         $this->signalDispatcher->emit(
  605.             new RemoveTranslationSignal(['contentId' => $contentInfo->id'languageCode' => $languageCode])
  606.         );
  607.         $this->signalDispatcher->emit(
  608.             new DeleteTranslationSignal(['contentId' => $contentInfo->id'languageCode' => $languageCode])
  609.         );
  610.     }
  611.     /**
  612.      * Delete specified Translation from a Content Draft.
  613.      *
  614.      * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the specified Translation
  615.      *         is the only one the Content Draft has or it is the main Translation of a Content Object.
  616.      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed
  617.      *         to edit the Content (in one of the locations of the given Content Object).
  618.      * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if languageCode argument
  619.      *         is invalid for the given Draft.
  620.      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if specified Version was not found
  621.      *
  622.      * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo Content Version Draft
  623.      * @param string $languageCode Language code of the Translation to be removed
  624.      *
  625.      * @return \eZ\Publish\API\Repository\Values\Content\Content Content Draft w/o the specified Translation
  626.      *
  627.      * @since 6.12
  628.      */
  629.     public function deleteTranslationFromDraft(VersionInfo $versionInfo$languageCode)
  630.     {
  631.         return $this->service->deleteTranslationFromDraft($versionInfo$languageCode);
  632.     }
  633.     /**
  634.      * Bulk-load Content items by the list of ContentInfo Value Objects.
  635.      *
  636.      * Note: it does not throw exceptions on load, just ignores erroneous Content item.
  637.      * Moreover, since the method works on pre-loaded ContentInfo list, it is assumed that user is
  638.      * allowed to access every Content on the list.
  639.      *
  640.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList
  641.      * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
  642.      *                            returned value object. If not given all languages are returned.
  643.      * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,
  644.      *                                 unless all languages have been asked for.
  645.      *
  646.      * @return \eZ\Publish\API\Repository\Values\Content\Content[] list of Content items with Content Ids as keys
  647.      */
  648.     public function loadContentListByContentInfo(
  649.         array $contentInfoList,
  650.         array $languages = [],
  651.         $useAlwaysAvailable true
  652.     ) {
  653.         return $this->service->loadContentListByContentInfo(
  654.             $contentInfoList,
  655.             $languages,
  656.             $useAlwaysAvailable
  657.         );
  658.     }
  659.     /**
  660.      * Hides Content by making all the Locations appear hidden.
  661.      * It does not persist hidden state on Location object itself.
  662.      *
  663.      * Content hidden by this API can be revealed by revealContent API.
  664.      *
  665.      * @see revealContent
  666.      *
  667.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  668.      */
  669.     public function hideContent(ContentInfo $contentInfo): void
  670.     {
  671.         $this->service->hideContent($contentInfo);
  672.         $this->signalDispatcher->emit(
  673.             new HideContentSignal([
  674.                 'contentId' => $contentInfo->id,
  675.             ])
  676.         );
  677.     }
  678.     /**
  679.      * Reveals Content hidden by hideContent API.
  680.      * Locations which were hidden before hiding Content will remain hidden.
  681.      *
  682.      * @see hideContent
  683.      *
  684.      * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  685.      */
  686.     public function revealContent(ContentInfo $contentInfo): void
  687.     {
  688.         $this->service->revealContent($contentInfo);
  689.         $this->signalDispatcher->emit(
  690.             new RevealContentSignal([
  691.                 'contentId' => $contentInfo->id,
  692.             ])
  693.         );
  694.     }
  695.     /**
  696.      * Instantiates a new content create struct object.
  697.      *
  698.      * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
  699.      *
  700.      * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
  701.      * @param string $mainLanguageCode
  702.      *
  703.      * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
  704.      */
  705.     public function newContentCreateStruct(ContentType $contentType$mainLanguageCode)
  706.     {
  707.         return $this->service->newContentCreateStruct($contentType$mainLanguageCode);
  708.     }
  709.     /**
  710.      * Instantiates a new content meta data update struct.
  711.      *
  712.      * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
  713.      */
  714.     public function newContentMetadataUpdateStruct()
  715.     {
  716.         return $this->service->newContentMetadataUpdateStruct();
  717.     }
  718.     /**
  719.      * Instantiates a new content update struct.
  720.      *
  721.      * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
  722.      */
  723.     public function newContentUpdateStruct()
  724.     {
  725.         return $this->service->newContentUpdateStruct();
  726.     }
  727. }