vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Repository/SiteAccessAware/ContentService.php line 101

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