diff --git a/config/api_platform/resources/asset.yaml b/config/api_platform/resources/asset.yaml index d4998a710..924e3e4c7 100644 --- a/config/api_platform/resources/asset.yaml +++ b/config/api_platform/resources/asset.yaml @@ -12,15 +12,13 @@ resources: ApiPlatform\Metadata\Get: normalizationContext: groups: [ 'asset:read', 'asset:item:get', 'dependency:read', 'property:read', 'element:read', 'element:item:get'] - ApiPlatform\Metadata\Put: - ApiPlatform\Metadata\Post: ApiPlatform\Metadata\Delete: - ApiPlatform\Metadata\Patch: - provider: Pimcore\Bundle\StudioApiBundle\State\AssetProvider + provider: Pimcore\Bundle\StudioApiBundle\State\Asset\Provider + processor: Pimcore\Bundle\StudioApiBundle\State\Asset\Processor normalizationContext: groups: ['asset:read', 'dependency:read', 'property:read', 'element:read'] denormalizationContext: - groups: ['asset:write'] + groups: ['asset:write', 'element:write'] properties: id: identifier: true diff --git a/config/api_platform/resources/asset/image.yaml b/config/api_platform/resources/asset/image.yaml index 11f47d019..59f9f5934 100644 --- a/config/api_platform/resources/asset/image.yaml +++ b/config/api_platform/resources/asset/image.yaml @@ -1,14 +1,16 @@ resources: Pimcore\Bundle\StudioApiBundle\Dto\Asset\Image: - provider: Pimcore\Bundle\StudioApiBundle\State\AssetProvider + provider: Pimcore\Bundle\StudioApiBundle\State\Asset\Provider + processor: Pimcore\Bundle\StudioApiBundle\State\Asset\Processor operations: ApiPlatform\Metadata\Get: normalizationContext: groups: ['image:read', 'asset:read', 'asset:item:get', 'dependency:read', 'property:read', 'element:read', 'element:item:get' ] + ApiPlatform\Metadata\Put: properties: id: identifier: true normalizationContext: groups: ['image:read', 'asset:read', 'dependency:read', 'property:read', 'element:read'] denormalizationContext: - groups: ['image:write', 'asset:write'] + groups: ['image:write', 'asset:write', 'element:write'] diff --git a/config/serialization/asset.yaml b/config/serialization/asset.yaml index 245aad6a3..bcd33afb9 100644 --- a/config/serialization/asset.yaml +++ b/config/serialization/asset.yaml @@ -1,20 +1,20 @@ Pimcore\Bundle\StudioApiBundle\Dto\Asset: attributes: type: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] iconName: - groups: [ 'asset:read' ] + groups: [ 'asset:read' , 'asset:write'] children: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] filename: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] mimetype: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] metadata: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] customSettings: - groups: ['asset:item:get'] + groups: ['asset:item:get', 'asset:write'] hasMetaData: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] userPermissions: - groups: ['asset:read'] + groups: ['asset:read', 'asset:write'] diff --git a/config/serialization/asset/image.yaml b/config/serialization/asset/image.yaml index 1398e0ded..70059e174 100644 --- a/config/serialization/asset/image.yaml +++ b/config/serialization/asset/image.yaml @@ -1,19 +1,13 @@ Pimcore\Bundle\StudioApiBundle\Dto\Asset\Image: attributes: thumbnail: - groups: ['image:read', 'asset:read'] - format: - groups: ['image:read', 'asset:read'] + groups: ['image:read', 'asset:read', 'image:write'] dimensions: - groups: ['image:read', 'asset:read'] + groups: ['image:read', 'asset:read', 'image:write'] width: - groups: ['image:read', 'asset:read'] + groups: ['image:read', 'asset:read', 'image:write'] height: - groups: ['image:read', 'asset:read'] - animated: - groups: ['image:read', 'asset:read'] - vectorGraphic: - groups: ['image:read', 'asset:read'] + groups: ['image:read', 'asset:read', 'image:write'] # lowQualityPreviewDataUri: # groups: ['image:read'] # lowQualityPreviewPath: diff --git a/config/serialization/element.yaml b/config/serialization/element.yaml index fe0eb019a..eb7de15a5 100644 --- a/config/serialization/element.yaml +++ b/config/serialization/element.yaml @@ -1,36 +1,36 @@ Pimcore\Bundle\StudioApiBundle\Dto\Element: attributes: id: - groups: ['element:read'] + groups: ['element:read', 'element:write'] parentId: - groups: ['element:read'] + groups: ['element:read', 'element:write'] permissions: - groups: ['element:read'] + groups: ['element:read', 'element:write'] path: - groups: ['element:read'] + groups: ['element:read', 'element:write'] creationDate: - groups: ['element:read'] + groups: ['element:read', 'element:write'] modificationDate: - groups: ['element:read'] + groups: ['element:read', 'element:write'] userOwner: - groups: ['element:read'] + groups: ['element:read', 'element:write'] userModification: - groups: ['element:read'] + groups: ['element:read', 'element:write'] properties: - groups: ['element:item:get'] + groups: ['element:item:get', 'element:write'] versions: - groups: ['element:read'] + groups: ['element:read', 'element:write'] locked: - groups: ['element:read'] + groups: ['element:read', 'element:write'] lock: - groups: ['element:read'] + groups: ['element:read', 'element:write'] dependencies: - groups: ['element:item:get'] + groups: ['element:item:get', 'element:write'] scheduledTasks: - groups: ['element:item:get'] + groups: ['element:item:get', 'element:write'] versionCount: - groups: ['element:item:get'] + groups: ['element:item:get', 'element:write'] fullPath: - groups: ['element:read'] + groups: ['element:read', 'element:write'] userPermissions: - groups: ['element:read'] + groups: ['element:read', 'element:write'] diff --git a/config/services.yaml b/config/services.yaml index 83bf2f682..5f5f4180c 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -20,12 +20,13 @@ services: tags: [ 'controller.service_arguments' ] # Providers - Pimcore\Bundle\StudioApiBundle\State\AssetProvider: ~ + Pimcore\Bundle\StudioApiBundle\State\Asset\Provider: ~ Pimcore\Bundle\StudioApiBundle\State\UserProvider: ~ Pimcore\Bundle\StudioApiBundle\State\ScheduledTaskProvider: ~ Pimcore\Bundle\StudioApiBundle\State\VersionProvider: ~ # Processors + Pimcore\Bundle\StudioApiBundle\State\ResetPasswordProcessor: ~ Pimcore\Bundle\StudioApiBundle\State\Token\Create\Processor: ~ Pimcore\Bundle\StudioApiBundle\State\Token\Refresh\Processor: ~ @@ -70,12 +71,23 @@ services: Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\PermissionsHydratorInterface: class: Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\PermissionsHydrator + Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\Asset\ImageHydratorInterface: + class: Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\Asset\ImageHydrator + # Services Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\AssetHydratorServiceInterface: class: Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\AssetHydratorService arguments: $assetHydratorLocator: '@generic_data_index.asset_hydrator.service_locator' + Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\AssetHydratorServiceInterface: + class: Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\AssetHydratorService + arguments: + $assetHydratorLocator: '@pimcore_model_data.asset_hydrator.service_locator' + + Pimcore\Bundle\StudioApiBundle\Service\AssetServiceInterface: + class: Pimcore\Bundle\StudioApiBundle\Service\AssetService + Pimcore\Bundle\StudioApiBundle\Service\AssetSearchServiceInterface: class: Pimcore\Bundle\StudioApiBundle\Service\AssetSearchService @@ -126,3 +138,8 @@ services: Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Text: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\TextHydratorInterface' Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Unknown: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\UnknownHydratorInterface' Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Asset\SearchResult\SearchResultItem\Video: '@Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\Hydrator\Asset\VideoHydratorInterface' + + pimcore_model_data.asset_hydrator.service_locator: + class: Symfony\Component\DependencyInjection\ServiceLocator + arguments: + - Pimcore\Model\Asset\Image: '@Pimcore\Bundle\StudioApiBundle\Service\CoreData\V1\Hydrator\Asset\ImageHydratorInterface' \ No newline at end of file diff --git a/src/Dto/Asset/Image.php b/src/Dto/Asset/Image.php index a3d0f6ff9..2259d09e7 100644 --- a/src/Dto/Asset/Image.php +++ b/src/Dto/Asset/Image.php @@ -18,16 +18,13 @@ use Pimcore\Bundle\StudioApiBundle\Dto\Asset; -class Image extends Asset +final class Image extends Asset { //use MetaData\EmbeddedMetaDataTrait; public function __construct( - private readonly string $format, private readonly int $width, private readonly int $height, - private readonly bool $vectorGraphic, - private readonly bool $animated, private readonly string $thumbnailPath, string $iconName, bool $hasChildren, diff --git a/src/Service/AssetService.php b/src/Service/AssetService.php new file mode 100644 index 000000000..eb8e425a8 --- /dev/null +++ b/src/Service/AssetService.php @@ -0,0 +1,40 @@ +assetResolver->getById($id); + + if(!$asset) { + throw new NotFoundException('Asset not found'); + } + + return $asset; + } +} \ No newline at end of file diff --git a/src/Service/AssetServiceInterface.php b/src/Service/AssetServiceInterface.php new file mode 100644 index 000000000..500ccf4a1 --- /dev/null +++ b/src/Service/AssetServiceInterface.php @@ -0,0 +1,24 @@ +getWidth(), + $item->getHeight(), + '', + $this->iconService->getIconForAsset($item->getType(), $item->getMimeType()), + false, + $item->getType(), + $item->getFilename(), + $item->getMimeType(), + [], + false, + $item->getFullPath(), + $item->getId(), + $item->getParentId(), + $item->getPath(), + $item->getUserOwner(), + $item->getUserModification(), + $item->getLocked(), + $item->isLocked(), + $item->getCreationDate(), + $item->getModificationDate(), + new Permissions() + ); + } +} \ No newline at end of file diff --git a/src/Service/CoreData/V1/Hydrator/Asset/ImageHydratorInterface.php b/src/Service/CoreData/V1/Hydrator/Asset/ImageHydratorInterface.php new file mode 100644 index 000000000..430e85801 --- /dev/null +++ b/src/Service/CoreData/V1/Hydrator/Asset/ImageHydratorInterface.php @@ -0,0 +1,11 @@ +assetHydratorLocator->has($class)) { + return $this->assetHydratorLocator->get($class)->hydrate($item); + } + + return null; + //return new Asset($item->getId()); + } +} \ No newline at end of file diff --git a/src/Service/GenericData/V1/Hydrator/Asset/ImageHydrator.php b/src/Service/GenericData/V1/Hydrator/Asset/ImageHydrator.php index 107d65a77..a9733d271 100644 --- a/src/Service/GenericData/V1/Hydrator/Asset/ImageHydrator.php +++ b/src/Service/GenericData/V1/Hydrator/Asset/ImageHydrator.php @@ -33,11 +33,8 @@ public function __construct( public function hydrate(ImageItem $item): Image { return new Image( - 'muhFormat', // TODO: Implement format $item->getWidth(), $item->getHeight(), - false, // TODO: Implement isVectorGraphic - false,// TODO: Implement isAnimated $item->getThumbnail(), $this->iconService->getIconForAsset($item->getType(), $item->getMimeType()), $item->isHasChildren(), diff --git a/src/State/Asset/Processor.php b/src/State/Asset/Processor.php new file mode 100644 index 000000000..4ec91bda7 --- /dev/null +++ b/src/State/Asset/Processor.php @@ -0,0 +1,26 @@ +