Skip to content

Commit

Permalink
Merge branch '1.x' into 179-delete-user-and-folder
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Util/Constants/UserPermissions.php
  • Loading branch information
martineiber committed Jun 12, 2024
2 parents 949fa68 + 1bd195e commit 4ec4c82
Show file tree
Hide file tree
Showing 97 changed files with 1,269 additions and 226 deletions.
17 changes: 13 additions & 4 deletions config/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomSettingsHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomSettingsHydrator

Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomMetadataHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomMetadataHydrator

# Encoder
Pimcore\Bundle\StudioBackendBundle\Asset\Encoder\TextEncoderInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Encoder\TextEncoder

Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetService

Pimcore\Bundle\StudioBackendBundle\Asset\Service\CustomSettingsServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\CustomSettingsService
Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomSettingsServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomSettingsService

Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataService

Pimcore\Bundle\StudioBackendBundle\Asset\Service\DataServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\DataService
Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\TextServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\TextService

Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\ImageAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\CustomMetadataAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

Pimcore\Bundle\StudioBackendBundle\Asset\Patcher\Adapter\MetadataAdapter:
tags: [ 'pimcore.studio_backend.patch_adapter' ]
2 changes: 0 additions & 2 deletions config/data_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ services:
class: Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\Asset\UnknownHydrator
Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\Asset\VideoHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\Asset\VideoHydrator
Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\Asset\MetaDataHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\Asset\MetaDataHydrator

Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\AssetHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataIndex\Hydrator\AssetHydrator
Expand Down
8 changes: 8 additions & 0 deletions config/resolver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Pimcore\Bundle\StudioBackendBundle\Resolver\Element\ReferenceResolverInterface:
class: Pimcore\Bundle\StudioBackendBundle\Resolver\Element\ReferenceResolver
15 changes: 15 additions & 0 deletions config/thumbnails.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
Pimcore\Bundle\StudioBackendBundle\Thumbnail\Controller\:
resource: '../src/Thumbnail/Controller'
public: true
tags: [ 'controller.service_arguments' ]

Pimcore\Bundle\StudioBackendBundle\Thumbnail\Repository\ThumbnailRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\Thumbnail\Repository\ThumbnailRepository
3 changes: 3 additions & 0 deletions src/Asset/Attributes/Request/UpdateAssetRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use OpenApi\Attributes\Property;
use OpenApi\Attributes\RequestBody;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Property\UpdateAssetImage;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Property\UpdateCustomMetaData;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Property\UpdateParentId;
use Pimcore\Bundle\StudioBackendBundle\Property\Attributes\Property\UpdateElementProperties;

Expand All @@ -35,10 +36,12 @@ public function __construct()
parent::__construct(
required: true,
content: new JsonContent(
required: ['data'],
properties: [
new Property('data',
properties: [
new UpdateParentId(),
new UpdateCustomMetaData(),
new UpdateElementProperties(),
new UpdateAssetImage(),
],
Expand Down
9 changes: 3 additions & 6 deletions src/Asset/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Response\Property\AnyOfAsset;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\AssetSearchServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\OpenSearchFilterInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterServiceTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\SearchException;
use Pimcore\Bundle\StudioBackendBundle\Filter\Service\FilterServiceProviderInterface;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\ExcludeFoldersParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\IdSearchTermParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageParameter;
Expand All @@ -40,12 +37,13 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementTypes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -66,8 +64,7 @@ public function __construct(
* @throws InvalidFilterServiceTypeException|SearchException|InvalidQueryTypeException|InvalidFilterTypeException
*/
#[Route('/assets', name: 'pimcore_studio_api_assets', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Get(
path: self::API_PATH . '/assets',
operationId: 'getAssets',
Expand Down
76 changes: 76 additions & 0 deletions src/Asset/Controller/Data/CustomMetadataController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Data;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Schema\CustomMetadata;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Content\ItemsJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class CustomMetadataController extends AbstractApiController
{
use ElementProviderTrait;

public function __construct(
SerializerInterface $serializer,
private readonly CustomMetadataServiceInterface $customMetadataService
) {
parent::__construct($serializer);
}

/**
* @throws AccessDeniedException
*/
#[Route('/assets/{id}/custom-metadata', name: 'pimcore_studio_api_get_asset_custom_metadata', methods: ['GET'])]
#[IsGranted(UserPermissions::ASSETS->value)]
#[GET(
path: self::API_PATH . '/assets/{id}/custom-metadata',
operationId: 'getAssetCustomMetadataById',
description: 'Get custom metadata of an asset by its id by path parameter',
summary: 'Get custom metadata of an asset by id',
tags: [Tags::Assets->name]
)]
#[IdParameter(type: 'asset')]
#[SuccessResponse(
description: 'Array of custom metadata',
content: new ItemsJson(CustomMetadata::class)
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function getAssetCustomSettingsById(int $id): JsonResponse
{
return $this->jsonResponse(['items' => $this->customMetadataService->getCustomMetadata($id)]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller;
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Data;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Response\Content\CustomSettingsJson;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\CustomSettingsServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomSettingsServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -49,7 +51,7 @@ public function __construct(
* @throws AccessDeniedException
*/
#[Route('/assets/{id}/custom-settings', name: 'pimcore_studio_api_get_asset_custom_settings', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
#[IsGranted(UserPermissions::ASSETS->value)]
#[GET(
path: self::API_PATH . '/assets/{id}/custom-settings',
operationId: 'getAssetCustomSettingsById',
Expand Down
9 changes: 5 additions & 4 deletions src/Asset/Controller/Data/TextController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Data;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DataServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\TextServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
Expand All @@ -28,9 +28,11 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -42,7 +44,7 @@ final class TextController extends AbstractApiController

public function __construct(
SerializerInterface $serializer,
private readonly DataServiceInterface $dataService
private readonly TextServiceInterface $dataService

) {
parent::__construct($serializer);
Expand All @@ -52,8 +54,7 @@ public function __construct(
* @throws ElementNotFoundException|InvalidElementTypeException|MaxFileSizeExceededException
*/
#[Route('/assets/{id}/text', name: 'pimcore_studio_api_get_asset_data_text', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Get(
path: self::API_PATH . '/assets/{id}/text',
operationId: 'getAssetDataTextById',
Expand Down
5 changes: 3 additions & 2 deletions src/Asset/Controller/GetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -47,8 +49,7 @@ public function __construct(
* @throws ElementNotFoundException|SearchException
*/
#[Route('/assets/{id}', name: 'pimcore_studio_api_get_asset', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Get(
path: self::API_PATH . '/assets/{id}',
operationId: 'getAssetById',
Expand Down
6 changes: 3 additions & 3 deletions src/Asset/Controller/PatchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use OpenApi\Attributes\Patch;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Request\PatchAssetRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\PatchAssetParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\PatchErrorJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
Expand All @@ -28,9 +27,11 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Patcher\Service\PatchServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -46,8 +47,7 @@ public function __construct(
}

#[Route('/assets', name: 'pimcore_studio_api_patch_asset', methods: ['PATCH'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Patch(
path: self::API_PATH . '/assets',
operationId: 'patchAssetById',
Expand Down
5 changes: 3 additions & 2 deletions src/Asset/Controller/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Updater\Service\UpdateServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -47,8 +49,7 @@ public function __construct(
}

#[Route('/assets/{id}', name: 'pimcore_studio_api_update_asset', methods: ['PUT'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Put(
path: self::API_PATH . '/assets/{id}',
operationId: 'updateAssetById',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Asset\Event;
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Event\PreResponse;

use Pimcore\Bundle\StudioBackendBundle\Asset\Schema\Asset;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;
Expand Down
Loading

0 comments on commit 4ec4c82

Please sign in to comment.