vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/SiteAccessAware/ContentTypeService.php line 26

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. namespace eZ\Publish\Core\Repository\SiteAccessAware;
  7. use eZ\Publish\API\Repository\ContentTypeService as ContentTypeServiceInterface;
  8. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroupCreateStruct;
  9. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroupUpdateStruct;
  10. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeCreateStruct;
  11. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeUpdateStruct;
  12. use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct;
  13. use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct;
  14. use eZ\Publish\API\Repository\Values\ContentType\ContentType;
  15. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup;
  16. use eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft;
  17. use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
  18. use eZ\Publish\API\Repository\Values\User\User;
  19. use eZ\Publish\API\Repository\LanguageResolver;
  20. /**
  21.  * SiteAccess aware implementation of ContentTypeService injecting languages where needed.
  22.  */
  23. class ContentTypeService implements ContentTypeServiceInterface
  24. {
  25.     /** @var \eZ\Publish\API\Repository\ContentTypeService */
  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\ContentTypeService $service
  33.      * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
  34.      */
  35.     public function __construct(
  36.         ContentTypeServiceInterface $service,
  37.         LanguageResolver $languageResolver
  38.     ) {
  39.         $this->service $service;
  40.         $this->languageResolver $languageResolver;
  41.     }
  42.     public function createContentTypeGroup(ContentTypeGroupCreateStruct $contentTypeGroupCreateStruct): ContentTypeGroup
  43.     {
  44.         return $this->service->createContentTypeGroup($contentTypeGroupCreateStruct);
  45.     }
  46.     public function loadContentTypeGroup(int $contentTypeGroupId, array $prioritizedLanguages null): ContentTypeGroup
  47.     {
  48.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  49.         return $this->service->loadContentTypeGroup($contentTypeGroupId$prioritizedLanguages);
  50.     }
  51.     public function loadContentTypeGroupByIdentifier(string $contentTypeGroupIdentifier, array $prioritizedLanguages null): ContentTypeGroup
  52.     {
  53.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  54.         return $this->service->loadContentTypeGroupByIdentifier($contentTypeGroupIdentifier$prioritizedLanguages);
  55.     }
  56.     public function loadContentTypeGroups(array $prioritizedLanguages null): iterable
  57.     {
  58.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  59.         return $this->service->loadContentTypeGroups($prioritizedLanguages);
  60.     }
  61.     public function updateContentTypeGroup(ContentTypeGroup $contentTypeGroupContentTypeGroupUpdateStruct $contentTypeGroupUpdateStruct): void
  62.     {
  63.         $this->service->updateContentTypeGroup($contentTypeGroup$contentTypeGroupUpdateStruct);
  64.     }
  65.     public function deleteContentTypeGroup(ContentTypeGroup $contentTypeGroup): void
  66.     {
  67.         $this->service->deleteContentTypeGroup($contentTypeGroup);
  68.     }
  69.     public function createContentType(ContentTypeCreateStruct $contentTypeCreateStruct, array $contentTypeGroups): ContentTypeDraft
  70.     {
  71.         return $this->service->createContentType($contentTypeCreateStruct$contentTypeGroups);
  72.     }
  73.     public function loadContentType(int $contentTypeId, array $prioritizedLanguages null): ContentType
  74.     {
  75.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  76.         return $this->service->loadContentType($contentTypeId$prioritizedLanguages);
  77.     }
  78.     public function loadContentTypeByIdentifier(string $identifier, array $prioritizedLanguages null): ContentType
  79.     {
  80.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  81.         return $this->service->loadContentTypeByIdentifier($identifier$prioritizedLanguages);
  82.     }
  83.     public function loadContentTypeByRemoteId(string $remoteId, array $prioritizedLanguages null): ContentType
  84.     {
  85.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  86.         return $this->service->loadContentTypeByRemoteId($remoteId$prioritizedLanguages);
  87.     }
  88.     public function loadContentTypeDraft(int $contentTypeIdbool $ignoreOwnership false): ContentTypeDraft
  89.     {
  90.         return $this->service->loadContentTypeDraft($contentTypeId$ignoreOwnership);
  91.     }
  92.     public function loadContentTypeList(array $contentTypeIds, array $prioritizedLanguages null): iterable
  93.     {
  94.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  95.         return $this->service->loadContentTypeList($contentTypeIds$prioritizedLanguages);
  96.     }
  97.     public function loadContentTypes(ContentTypeGroup $contentTypeGroup, array $prioritizedLanguages null): iterable
  98.     {
  99.         $prioritizedLanguages $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages);
  100.         return $this->service->loadContentTypes($contentTypeGroup$prioritizedLanguages);
  101.     }
  102.     public function createContentTypeDraft(ContentType $contentType): ContentTypeDraft
  103.     {
  104.         return $this->service->createContentTypeDraft($contentType);
  105.     }
  106.     public function updateContentTypeDraft(ContentTypeDraft $contentTypeDraftContentTypeUpdateStruct $contentTypeUpdateStruct): void
  107.     {
  108.         $this->service->updateContentTypeDraft($contentTypeDraft$contentTypeUpdateStruct);
  109.     }
  110.     public function deleteContentType(ContentType $contentType): void
  111.     {
  112.         $this->service->deleteContentType($contentType);
  113.     }
  114.     public function copyContentType(ContentType $contentTypeUser $creator null): ContentType
  115.     {
  116.         return $this->service->copyContentType($contentType$creator);
  117.     }
  118.     public function assignContentTypeGroup(ContentType $contentTypeContentTypeGroup $contentTypeGroup): void
  119.     {
  120.         $this->service->assignContentTypeGroup($contentType$contentTypeGroup);
  121.     }
  122.     public function unassignContentTypeGroup(ContentType $contentTypeContentTypeGroup $contentTypeGroup): void
  123.     {
  124.         $this->service->unassignContentTypeGroup($contentType$contentTypeGroup);
  125.     }
  126.     public function addFieldDefinition(ContentTypeDraft $contentTypeDraftFieldDefinitionCreateStruct $fieldDefinitionCreateStruct): void
  127.     {
  128.         $this->service->addFieldDefinition($contentTypeDraft$fieldDefinitionCreateStruct);
  129.     }
  130.     public function removeFieldDefinition(ContentTypeDraft $contentTypeDraftFieldDefinition $fieldDefinition): void
  131.     {
  132.         $this->service->removeFieldDefinition($contentTypeDraft$fieldDefinition);
  133.     }
  134.     public function updateFieldDefinition(ContentTypeDraft $contentTypeDraftFieldDefinition $fieldDefinitionFieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct): void
  135.     {
  136.         $this->service->updateFieldDefinition($contentTypeDraft$fieldDefinition$fieldDefinitionUpdateStruct);
  137.     }
  138.     public function publishContentTypeDraft(ContentTypeDraft $contentTypeDraft): void
  139.     {
  140.         $this->service->publishContentTypeDraft($contentTypeDraft);
  141.     }
  142.     public function newContentTypeGroupCreateStruct(string $identifier): ContentTypeGroupCreateStruct
  143.     {
  144.         return $this->service->newContentTypeGroupCreateStruct($identifier);
  145.     }
  146.     public function newContentTypeCreateStruct(string $identifier): ContentTypeCreateStruct
  147.     {
  148.         return $this->service->newContentTypeCreateStruct($identifier);
  149.     }
  150.     public function newContentTypeUpdateStruct(): ContentTypeUpdateStruct
  151.     {
  152.         return $this->service->newContentTypeUpdateStruct();
  153.     }
  154.     public function newContentTypeGroupUpdateStruct(): ContentTypeGroupUpdateStruct
  155.     {
  156.         return $this->service->newContentTypeGroupUpdateStruct();
  157.     }
  158.     public function newFieldDefinitionCreateStruct(string $identifierstring $fieldTypeIdentifier): FieldDefinitionCreateStruct
  159.     {
  160.         return $this->service->newFieldDefinitionCreateStruct($identifier$fieldTypeIdentifier);
  161.     }
  162.     public function newFieldDefinitionUpdateStruct(): FieldDefinitionUpdateStruct
  163.     {
  164.         return $this->service->newFieldDefinitionUpdateStruct();
  165.     }
  166.     public function isContentTypeUsed(ContentType $contentType): bool
  167.     {
  168.         return $this->service->isContentTypeUsed($contentType);
  169.     }
  170.     public function removeContentTypeTranslation(ContentTypeDraft $contentTypeDraftstring $languageCode): ContentTypeDraft
  171.     {
  172.         return $this->service->removeContentTypeTranslation($contentTypeDraft$languageCode);
  173.     }
  174.     public function deleteUserDrafts(int $userId): void
  175.     {
  176.         $this->service->deleteUserDrafts($userId);
  177.     }
  178. }