vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/SiteAccessAware/ContentService.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace eZ\Publish\Core\Repository\SiteAccessAware;
  8. use eZ\Publish\API\Repository\ContentService as ContentServiceInterface;
  9. use eZ\Publish\API\Repository\Values\Content\ContentDraftList;
  10. use eZ\Publish\API\Repository\Values\Content\ContentCreateStruct;
  11. use eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct;
  12. use eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct;
  13. use eZ\Publish\API\Repository\Values\Content\Content;
  14. use eZ\Publish\API\Repository\Values\Content\Relation;
  15. use eZ\Publish\API\Repository\Values\Content\Language;
  16. use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
  17. use eZ\Publish\API\Repository\Values\Content\RelationList;
  18. use eZ\Publish\API\Repository\Values\ContentType\ContentType;
  19. use eZ\Publish\API\Repository\Values\User\User;
  20. use eZ\Publish\API\Repository\Values\Content\VersionInfo;
  21. use eZ\Publish\API\Repository\Values\Content\ContentInfo;
  22. use eZ\Publish\API\Repository\LanguageResolver;
  23. use eZ\Publish\API\Repository\Values\Content\ContentList;
  24. use eZ\Publish\API\Repository\Values\Filter\Filter;
  25. use eZ\Publish\API\Repository\Values\ValueObject;
  26. /**
  27.  * SiteAccess aware implementation of ContentService injecting languages where needed.
  28.  */
  29. class ContentService implements ContentServiceInterface
  30. {
  31.     /** @var \eZ\Publish\API\Repository\ContentService */
  32.     protected $service;
  33.     /** @var \eZ\Publish\API\Repository\LanguageResolver */
  34.     protected $languageResolver;
  35.     /**
  36.      * Construct service object from aggregated service and LanguageResolver.
  37.      *
  38.      * @param \eZ\Publish\API\Repository\ContentService $service
  39.      * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
  40.      */
  41.     public function __construct(
  42.         ContentServiceInterface $service,
  43.         LanguageResolver $languageResolver
  44.     ) {
  45.         $this->service $service;
  46.         $this->languageResolver $languageResolver;
  47.     }
  48.     public function loadContentInfo(int $contentId): ContentInfo
  49.     {
  50.         return $this->service->loadContentInfo($contentId);
  51.     }
  52.     /**
  53.      * {@inheritdoc}
  54.      */
  55.     public function loadContentInfoList(array $contentIds): iterable
  56.     {
  57.         return $this->service->loadContentInfoList($contentIds);
  58.     }
  59.     public function loadContentInfoByRemoteId(string $remoteId): ContentInfo
  60.     {
  61.         return $this->service->loadContentInfoByRemoteId($remoteId);
  62.     }
  63.     public function loadVersionInfo(ContentInfo $contentInfo, ?int $versionNo null): VersionInfo
  64.     {
  65.         return $this->service->loadVersionInfo($contentInfo$versionNo);
  66.     }
  67.     public function loadVersionInfoById(int $contentId, ?int $versionNo null): VersionInfo
  68.     {
  69.         return $this->service->loadVersionInfoById($contentId$versionNo);
  70.     }
  71.     public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages null, ?int $versionNo nullbool $useAlwaysAvailable true): Content
  72.     {
  73.         return $this->service->loadContentByContentInfo(
  74.             $contentInfo,
  75.             $this->languageResolver->getPrioritizedLanguages($languages),
  76.             $versionNo,
  77.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  78.         );
  79.     }
  80.     public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages nullbool $useAlwaysAvailable true): Content
  81.     {
  82.         return $this->service->loadContentByVersionInfo(
  83.             $versionInfo,
  84.             $this->languageResolver->getPrioritizedLanguages($languages),
  85.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  86.         );
  87.     }
  88.     public function loadContent(int $contentId, array $languages null, ?int $versionNo nullbool $useAlwaysAvailable true): Content
  89.     {
  90.         return $this->service->loadContent(
  91.             $contentId,
  92.             $this->languageResolver->getPrioritizedLanguages($languages),
  93.             $versionNo,
  94.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  95.         );
  96.     }
  97.     public function loadContentByRemoteId(string $remoteId, array $languages null, ?int $versionNo nullbool $useAlwaysAvailable true): Content
  98.     {
  99.         return $this->service->loadContentByRemoteId(
  100.             $remoteId,
  101.             $this->languageResolver->getPrioritizedLanguages($languages),
  102.             $versionNo,
  103.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  104.         );
  105.     }
  106.     public function createContent(
  107.         ContentCreateStruct $contentCreateStruct,
  108.         array $locationCreateStructs = [],
  109.         ?array $fieldIdentifiersToValidate null
  110.     ): Content {
  111.         return $this->service->createContent($contentCreateStruct$locationCreateStructs$fieldIdentifiersToValidate);
  112.     }
  113.     public function updateContentMetadata(ContentInfo $contentInfoContentMetadataUpdateStruct $contentMetadataUpdateStruct): Content
  114.     {
  115.         return $this->service->updateContentMetadata($contentInfo$contentMetadataUpdateStruct);
  116.     }
  117.     public function deleteContent(ContentInfo $contentInfo): iterable
  118.     {
  119.         return $this->service->deleteContent($contentInfo);
  120.     }
  121.     public function createContentDraft(
  122.         ContentInfo $contentInfo,
  123.         ?VersionInfo $versionInfo null,
  124.         ?User $creator null,
  125.         ?Language $language null
  126.     ): Content {
  127.         return $this->service->createContentDraft($contentInfo$versionInfo$creator$language);
  128.     }
  129.     public function countContentDrafts(?User $user null): int
  130.     {
  131.         return $this->service->countContentDrafts($user);
  132.     }
  133.     public function loadContentDrafts(?User $user null): iterable
  134.     {
  135.         return $this->service->loadContentDrafts($user);
  136.     }
  137.     public function loadContentDraftList(?User $user nullint $offset 0int $limit = -1): ContentDraftList
  138.     {
  139.         return $this->service->loadContentDraftList($user$offset$limit);
  140.     }
  141.     public function updateContent(VersionInfo $versionInfoContentUpdateStruct $contentUpdateStruct, ?array $fieldIdentifiersToValidate null): Content
  142.     {
  143.         return $this->service->updateContent($versionInfo$contentUpdateStruct$fieldIdentifiersToValidate);
  144.     }
  145.     public function publishVersion(VersionInfo $versionInfo, array $translations Language::ALL): Content
  146.     {
  147.         return $this->service->publishVersion($versionInfo$translations);
  148.     }
  149.     public function deleteVersion(VersionInfo $versionInfo): void
  150.     {
  151.         $this->service->deleteVersion($versionInfo);
  152.     }
  153.     public function loadVersions(ContentInfo $contentInfo, ?int $status null): iterable
  154.     {
  155.         return $this->service->loadVersions($contentInfo$status);
  156.     }
  157.     public function copyContent(ContentInfo $contentInfoLocationCreateStruct $destinationLocationCreateStruct, ?VersionInfo $versionInfo null): Content
  158.     {
  159.         return $this->service->copyContent($contentInfo$destinationLocationCreateStruct$versionInfo);
  160.     }
  161.     public function loadRelations(VersionInfo $versionInfo): iterable
  162.     {
  163.         return $this->service->loadRelations($versionInfo);
  164.     }
  165.     /**
  166.      * {@inheritdoc}
  167.      */
  168.     public function countReverseRelations(ContentInfo $contentInfo): int
  169.     {
  170.         return $this->service->countReverseRelations($contentInfo);
  171.     }
  172.     public function loadReverseRelations(ContentInfo $contentInfo): iterable
  173.     {
  174.         return $this->service->loadReverseRelations($contentInfo);
  175.     }
  176.     public function loadReverseRelationList(ContentInfo $contentInfoint $offset 0int $limit = -1): RelationList
  177.     {
  178.         return $this->service->loadReverseRelationList($contentInfo$offset$limit);
  179.     }
  180.     public function addRelation(VersionInfo $sourceVersionContentInfo $destinationContent): Relation
  181.     {
  182.         return $this->service->addRelation($sourceVersion$destinationContent);
  183.     }
  184.     public function deleteRelation(VersionInfo $sourceVersionContentInfo $destinationContent): void
  185.     {
  186.         $this->service->deleteRelation($sourceVersion$destinationContent);
  187.     }
  188.     public function deleteTranslation(ContentInfo $contentInfostring $languageCode): void
  189.     {
  190.         $this->service->deleteTranslation($contentInfo$languageCode);
  191.     }
  192.     public function deleteTranslationFromDraft(VersionInfo $versionInfostring $languageCode): Content
  193.     {
  194.         return $this->service->deleteTranslationFromDraft($versionInfo$languageCode);
  195.     }
  196.     public function loadContentListByContentInfo(array $contentInfoList, array $languages nullbool $useAlwaysAvailable true): iterable
  197.     {
  198.         return $this->service->loadContentListByContentInfo(
  199.             $contentInfoList,
  200.             $this->languageResolver->getPrioritizedLanguages($languages),
  201.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  202.         );
  203.     }
  204.     public function hideContent(ContentInfo $contentInfo): void
  205.     {
  206.         $this->service->hideContent($contentInfo);
  207.     }
  208.     public function revealContent(ContentInfo $contentInfo): void
  209.     {
  210.         $this->service->revealContent($contentInfo);
  211.     }
  212.     public function newContentCreateStruct(ContentType $contentTypestring $mainLanguageCode): ContentCreateStruct
  213.     {
  214.         return $this->service->newContentCreateStruct($contentType$mainLanguageCode);
  215.     }
  216.     public function newContentMetadataUpdateStruct(): ContentMetadataUpdateStruct
  217.     {
  218.         return $this->service->newContentMetadataUpdateStruct();
  219.     }
  220.     public function newContentUpdateStruct(): ContentUpdateStruct
  221.     {
  222.         return $this->service->newContentUpdateStruct();
  223.     }
  224.     public function validate(
  225.         ValueObject $object,
  226.         array $context,
  227.         ?array $fieldIdentifiersToValidate null
  228.     ): array {
  229.         return $this->service->validate($object$context$fieldIdentifiersToValidate);
  230.     }
  231.     public function find(Filter $filter, ?array $languages null): ContentList
  232.     {
  233.         return $this->service->find(
  234.             $filter,
  235.             $this->languageResolver->getPrioritizedLanguages($languages)
  236.         );
  237.     }
  238. }