From 30711dec319a9e52c51c65f34500a3199c20fb5e Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Wed, 9 Oct 2024 10:45:42 +0200 Subject: [PATCH 1/7] [Grid] [Asset] Predefined Metadata should be localizable. (#475) --- src/Grid/Column/Collector/Asset/MetadataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Grid/Column/Collector/Asset/MetadataCollector.php b/src/Grid/Column/Collector/Asset/MetadataCollector.php index 3ed39371..8078fb67 100644 --- a/src/Grid/Column/Collector/Asset/MetadataCollector.php +++ b/src/Grid/Column/Collector/Asset/MetadataCollector.php @@ -98,7 +98,7 @@ private function getPredefinedMetadata(array $availableColumnDefinitions): array group: 'predefined_metadata', sortable: $availableColumnDefinitions[$type]->isSortable(), editable: true, - localizable: false, + localizable: true, locale: null, type: $type, frontendType: $availableColumnDefinitions[$type]->getFrontendType(), From e59e9a01849fbc2f8d05af6e7713dc7bb4dc3749 Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Wed, 9 Oct 2024 13:12:51 +0200 Subject: [PATCH 2/7] use CustomMetadataServiceInterface (#474) --- src/Grid/Column/Collector/Asset/MetadataCollector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Grid/Column/Collector/Asset/MetadataCollector.php b/src/Grid/Column/Collector/Asset/MetadataCollector.php index 8078fb67..6514eb4a 100644 --- a/src/Grid/Column/Collector/Asset/MetadataCollector.php +++ b/src/Grid/Column/Collector/Asset/MetadataCollector.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\StudioBackendBundle\Grid\Column\Collector\Asset; +use Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ColumnCollectorInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ColumnDefinitionInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\FrontendType; @@ -58,7 +59,7 @@ public function getColumnConfigurations(array $availableColumnDefinitions): arra */ private function getDefaultMetadata(): array { - $defaultMetadata = ['title', 'alt', 'copyright']; + $defaultMetadata = CustomMetadataServiceInterface::DEFAULT_METADATA; $columns = []; foreach ($defaultMetadata as $metadata) { $columns[] = new ColumnConfiguration( From d8b7ce32ff82462ebdabfdfec1b9921aa8e85259 Mon Sep 17 00:00:00 2001 From: Matthias Schuhmayer <38959016+mattamon@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:26:55 +0200 Subject: [PATCH 3/7] [Bug] Async processes do not have user in session (#478) * Async processes do not have user in session. Use user from jobrun instead * Remove security service * Apply php-cs-fixer changes --------- Co-authored-by: mattamon --- .../Messenger/Handler/PatchHandler.php | 7 ++++++- src/Patcher/Service/PatchService.php | 11 +++++------ src/Patcher/Service/PatchServiceInterface.php | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Element/ExecutionEngine/AutomationAction/Messenger/Handler/PatchHandler.php b/src/Element/ExecutionEngine/AutomationAction/Messenger/Handler/PatchHandler.php index e01a0e4d..ae579539 100644 --- a/src/Element/ExecutionEngine/AutomationAction/Messenger/Handler/PatchHandler.php +++ b/src/Element/ExecutionEngine/AutomationAction/Messenger/Handler/PatchHandler.php @@ -87,7 +87,12 @@ public function __invoke(PatchMessage $message): void } try { - $this->patchService->patchElement($element, $elementType, $jobEnvironmentData[$elementId]); + $this->patchService->patchElement( + $element, + $elementType, + $jobEnvironmentData[$elementId], + $validatedParameters->getUser() + ); } catch (Exception $exception) { $this->abort($this->getAbortData( Config::ELEMENT_PATCH_FAILED_MESSAGE->value, diff --git a/src/Patcher/Service/PatchService.php b/src/Patcher/Service/PatchService.php index 47de3b03..3dc6a8b6 100644 --- a/src/Patcher/Service/PatchService.php +++ b/src/Patcher/Service/PatchService.php @@ -30,7 +30,6 @@ use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; use Pimcore\Bundle\StudioBackendBundle\ExecutionEngine\Util\Config; use Pimcore\Bundle\StudioBackendBundle\ExecutionEngine\Util\Jobs; -use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; use Pimcore\Model\Element\ElementDescriptor; use Pimcore\Model\Element\ElementInterface; use Pimcore\Model\UserInterface; @@ -45,8 +44,7 @@ public function __construct( private SynchronousProcessingServiceInterface $synchronousProcessingService, private JobExecutionAgentInterface $jobExecutionAgent, private ElementServiceInterface $elementService, - private AdapterLoaderInterface $adapterLoader, - private SecurityServiceInterface $securityService, + private AdapterLoaderInterface $adapterLoader ) { } @@ -63,7 +61,7 @@ public function patch( } $element = $this->elementService->getAllowedElementById($elementType, $patchData[0]['id'], $user); - $this->patchElement($element, $elementType, $patchData[0]); + $this->patchElement($element, $elementType, $patchData[0], $user); return null; } @@ -74,7 +72,8 @@ public function patch( public function patchElement( ElementInterface $element, string $elementType, - array $elementPatchData + array $elementPatchData, + UserInterface $user, ): void { try { $adapters = $this->adapterLoader->loadAdapters($elementType); @@ -83,7 +82,7 @@ public function patchElement( } $this->synchronousProcessingService->enable(); - $element->setUserModification($this->securityService->getCurrentUser()->getId()); + $element->setUserModification($user->getId()); $element->save(); } catch (Exception $exception) { throw new ElementSavingFailedException($element->getId(), $exception->getMessage()); diff --git a/src/Patcher/Service/PatchServiceInterface.php b/src/Patcher/Service/PatchServiceInterface.php index aeba79d8..941a79c5 100644 --- a/src/Patcher/Service/PatchServiceInterface.php +++ b/src/Patcher/Service/PatchServiceInterface.php @@ -43,6 +43,7 @@ public function patch( public function patchElement( ElementInterface $element, string $elementType, - array $elementPatchData + array $elementPatchData, + UserInterface $user ): void; } From 387ccecf1b9175bad50cf0de326f77558da71958 Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Thu, 10 Oct 2024 08:15:58 +0200 Subject: [PATCH 4/7] [Grid] [Asset] Save Configuration shared User and role can be empty. (#479) --- .../MappedParameter/Grid/SaveConfigurationParameter.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Asset/MappedParameter/Grid/SaveConfigurationParameter.php b/src/Asset/MappedParameter/Grid/SaveConfigurationParameter.php index f1a673a9..16aeddf4 100644 --- a/src/Asset/MappedParameter/Grid/SaveConfigurationParameter.php +++ b/src/Asset/MappedParameter/Grid/SaveConfigurationParameter.php @@ -37,11 +37,9 @@ public function __construct( #[NotBlank] private string $description, #[NotBlank] - private array $sharedUsers, - #[NotBlank] - private array $sharedRoles, - #[NotBlank] private array $columns, + private array $sharedUsers = [], + private array $sharedRoles = [], private ?Filter $filter = null, private bool $saveFilter = false, private bool $shareGlobal = false, From 52f54a1e5422147dac2be0470475e259647d1b8b Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Fri, 11 Oct 2024 10:15:39 +0200 Subject: [PATCH 5/7] [Grid] [Dataobject] Add Folder ID to custom layout getter. (#480) --- .../Column/Collector/DataObject/FieldDefinitionCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php b/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php index b8ec1690..6a553204 100644 --- a/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php +++ b/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php @@ -71,7 +71,7 @@ public function getColumnConfigurations(array $availableColumnDefinitions): arra $filteredDefinitions = $this->dataObjectServiceResolver->getCustomLayoutDefinitionForGridColumnConfig( $classDefinition, - 744 + $this->getFolderId() ); if (!isset($filteredDefinitions['layoutDefinition'])) { From bbfc3bd3dc48fd6176fd28b5a87a618a4aaf09a0 Mon Sep 17 00:00:00 2001 From: Matthias Schuhmayer <38959016+mattamon@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:44:54 +0200 Subject: [PATCH 6/7] [Improvement] Add configurable prefix (#486) * Add configurable prefix * Apply php-cs-fixer changes --------- Co-authored-by: mattamon --- config/pimcore/routing.yaml | 4 ++-- doc/10_Extending_Studio/01_Endpoints.md | 3 ++- src/Asset/Controller/CloneController.php | 2 +- .../Controller/Data/CustomMetadataController.php | 2 +- .../Controller/Data/CustomSettingsController.php | 2 +- src/Asset/Controller/Data/TextController.php | 2 +- .../Controller/Document/PreviewStreamController.php | 2 +- .../Controller/Download/CreateCsvController.php | 2 +- .../Controller/Download/CreateZipController.php | 2 +- .../Controller/Download/DeleteCsvController.php | 2 +- .../Controller/Download/DeleteZipController.php | 2 +- .../Controller/Download/DownloadCsvController.php | 2 +- .../Controller/Download/DownloadZipController.php | 2 +- src/Asset/Controller/DownloadController.php | 2 +- src/Asset/Controller/GetController.php | 2 +- .../Configuration/GetAvailableColumnsController.php | 2 +- .../Configuration/GetConfigurationController.php | 2 +- .../ListSavedConfigurationsController.php | 2 +- .../Configuration/SaveConfigurationController.php | 2 +- .../Grid/Configuration/SetAsFavoriteController.php | 2 +- .../Configuration/UpdateConfigurationController.php | 2 +- src/Asset/Controller/Grid/GetController.php | 2 +- .../Controller/Image/CustomDownloadController.php | 2 +- .../Controller/Image/FormatDownloadController.php | 2 +- .../Image/ThumbnailDownloadController.php | 2 +- src/Asset/Controller/PatchController.php | 2 +- src/Asset/Controller/TreeController.php | 2 +- src/Asset/Controller/UpdateController.php | 2 +- src/Asset/Controller/Upload/AddController.php | 2 +- src/Asset/Controller/Upload/InfoController.php | 2 +- src/Asset/Controller/Upload/ReplaceController.php | 2 +- src/Asset/Controller/Upload/ZipController.php | 2 +- .../Video/ImageThumbnailStreamController.php | 2 +- .../Video/ThumbnailDownloadController.php | 2 +- .../Controller/Video/ThumbnailStreamController.php | 2 +- src/Authorization/Controller/LoginController.php | 2 +- src/Authorization/Controller/LogoutController.php | 2 +- src/Controller/AbstractApiController.php | 13 ++++--------- src/DataObject/Controller/AddController.php | 2 +- src/DataObject/Controller/CloneController.php | 2 +- src/DataObject/Controller/GetController.php | 2 +- .../Grid/GetAvailableColumnsController.php | 2 +- src/DataObject/Controller/Grid/GetController.php | 2 +- src/DataObject/Controller/PatchController.php | 2 +- src/DataObject/Controller/ReplaceController.php | 2 +- src/DataObject/Controller/TreeController.php | 2 +- src/DataObject/Controller/UpdateController.php | 2 +- .../Controller/Element/CollectionController.php | 2 +- src/DependencyInjection/Configuration.php | 9 +++++++++ .../PimcoreStudioBackendExtension.php | 6 +++++- src/Element/Controller/DeleteController.php | 2 +- src/Element/Controller/DeleteInfoController.php | 2 +- src/Element/Controller/FolderController.php | 2 +- src/Element/Controller/GetIdByPathController.php | 2 +- src/Email/Controller/Blocklist/AddController.php | 2 +- .../Controller/Blocklist/CollectionController.php | 2 +- src/Email/Controller/Blocklist/DeleteController.php | 2 +- src/Email/Controller/CollectionController.php | 2 +- src/Email/Controller/DeleteController.php | 2 +- src/Email/Controller/Detail/EmailHtmlController.php | 2 +- .../Controller/Detail/EmailParamsController.php | 2 +- src/Email/Controller/Detail/EmailTextController.php | 2 +- src/Email/Controller/Detail/GetController.php | 2 +- src/Email/Controller/ForwardController.php | 2 +- src/Email/Controller/ResendController.php | 2 +- src/Email/Controller/TestEmailController.php | 2 +- src/ExecutionEngine/Controller/AbortController.php | 2 +- src/Mercure/Controller/JwtController.php | 2 +- src/Note/Controller/CollectionController.php | 2 +- src/Note/Controller/DeleteController.php | 2 +- .../Controller/Element/CollectionController.php | 2 +- src/Note/Controller/Element/CreateController.php | 2 +- src/Note/Controller/Element/TypeController.php | 2 +- .../Controller/CollectionController.php | 2 +- src/Notification/Controller/DeleteAllController.php | 2 +- src/Notification/Controller/DeleteController.php | 2 +- src/Notification/Controller/GetController.php | 2 +- src/Notification/Controller/ReadController.php | 2 +- src/Notification/Controller/SendController.php | 2 +- src/OpenApi/Service/OpenApiService.php | 13 +++++++++++++ src/Property/Controller/CollectionController.php | 2 +- src/Property/Controller/CreateController.php | 2 +- src/Property/Controller/DeleteController.php | 2 +- .../Controller/Element/CollectionController.php | 2 +- src/Property/Controller/UpdateController.php | 2 +- src/Role/Controller/CloneController.php | 2 +- src/Role/Controller/CreateFolderController.php | 2 +- src/Role/Controller/CreateRoleController.php | 2 +- src/Role/Controller/DeleteFolderController.php | 2 +- src/Role/Controller/DeleteRoleController.php | 2 +- src/Role/Controller/GetRoleController.php | 2 +- src/Role/Controller/GetRolesController.php | 2 +- src/Role/Controller/RoleTreeController.php | 2 +- src/Role/Controller/UpdateRoleController.php | 2 +- src/Schedule/Controller/DeleteController.php | 2 +- .../Controller/Element/CollectionController.php | 2 +- .../Controller/Element/CreateController.php | 2 +- .../Controller/Element/UpdateController.php | 2 +- src/Setting/Controller/GetController.php | 2 +- src/Tag/Controller/CollectionController.php | 2 +- src/Tag/Controller/CreateController.php | 2 +- src/Tag/Controller/DeleteController.php | 2 +- src/Tag/Controller/Element/AssignController.php | 2 +- .../Controller/Element/BatchAssignController.php | 2 +- .../Controller/Element/BatchReplaceController.php | 2 +- src/Tag/Controller/Element/CollectionController.php | 2 +- src/Tag/Controller/Element/UnassignController.php | 2 +- src/Tag/Controller/GetController.php | 2 +- src/Tag/Controller/UpdateController.php | 2 +- .../Controller/ImageCollectionController.php | 2 +- .../Controller/VideoCollectionController.php | 2 +- .../Controller/TranslationController.php | 2 +- src/User/Controller/CloneController.php | 2 +- src/User/Controller/CreateUserController.php | 2 +- src/User/Controller/CreateUserFolderController.php | 2 +- src/User/Controller/CurrentUserController.php | 2 +- src/User/Controller/DeleteUserController.php | 2 +- src/User/Controller/DeleteUserFolderController.php | 2 +- src/User/Controller/GetUserController.php | 2 +- .../Controller/GetUserPermissionsController.php | 2 +- src/User/Controller/GetUsersController.php | 2 +- src/User/Controller/ResetPasswordController.php | 2 +- src/User/Controller/UpdatePasswordController.php | 2 +- src/User/Controller/UpdateUserController.php | 2 +- src/User/Controller/UserTreeController.php | 2 +- src/Util/Trait/StudioBackendPathTrait.php | 2 +- src/Version/Controller/Asset/DownloadController.php | 2 +- .../Controller/Asset/ImageStreamController.php | 2 +- .../Controller/Asset/PdfStreamController.php | 2 +- src/Version/Controller/DeleteController.php | 2 +- .../Controller/Element/CleanupController.php | 2 +- .../Controller/Element/CollectionController.php | 2 +- src/Version/Controller/GetController.php | 2 +- src/Version/Controller/PublishController.php | 2 +- src/Version/Controller/UpdateController.php | 2 +- .../Controller/DetailsCollectionController.php | 2 +- src/Workflow/Controller/SubmitActionController.php | 2 +- 137 files changed, 166 insertions(+), 144 deletions(-) diff --git a/config/pimcore/routing.yaml b/config/pimcore/routing.yaml index d0002943..b0d8099d 100644 --- a/config/pimcore/routing.yaml +++ b/config/pimcore/routing.yaml @@ -1,6 +1,6 @@ -studio_api: +pimcore_studio_api: resource: "../../src/" type: annotation - prefix: /studio/api + prefix: '%pimcore_studio_backend.url_prefix%' options: expose: true diff --git a/doc/10_Extending_Studio/01_Endpoints.md b/doc/10_Extending_Studio/01_Endpoints.md index ec0b9dde..aea141b6 100644 --- a/doc/10_Extending_Studio/01_Endpoints.md +++ b/doc/10_Extending_Studio/01_Endpoints.md @@ -27,6 +27,7 @@ To add a custom endpoint to the Pimcore Studio Backend you need to implement it - We try to leverage symfony functionality as much as possible for parameters with `#[MapQueryString]` or `#[MapRequestPayload]` attributes ### Example + ```php value)] #[Get( - path: self::API_PATH . '/notes', + path: self::PREFIX . '/notes', operationId: 'note_get_collection', description: 'note_get_collection_description', summary: 'note_get_collection_summary', diff --git a/src/Asset/Controller/CloneController.php b/src/Asset/Controller/CloneController.php index b8104145..1cbb996c 100644 --- a/src/Asset/Controller/CloneController.php +++ b/src/Asset/Controller/CloneController.php @@ -63,7 +63,7 @@ public function __construct( #[Route('/assets/{id}/clone/{parentId}', name: 'pimcore_studio_api_assets_clone', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/{id}/clone/{parentId}', + path: self::PREFIX . '/assets/{id}/clone/{parentId}', operationId: 'asset_clone', description: 'asset_clone_description', summary: 'asset_clone_summary', diff --git a/src/Asset/Controller/Data/CustomMetadataController.php b/src/Asset/Controller/Data/CustomMetadataController.php index 2448cfd4..d9224908 100644 --- a/src/Asset/Controller/Data/CustomMetadataController.php +++ b/src/Asset/Controller/Data/CustomMetadataController.php @@ -55,7 +55,7 @@ public function __construct( #[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', + path: self::PREFIX . '/assets/{id}/custom-metadata', operationId: 'asset_custom_metadata_get_by_id', description: 'asset_custom_metadata_get_by_id_description', summary: 'asset_custom_metadata_get_by_id_summary', diff --git a/src/Asset/Controller/Data/CustomSettingsController.php b/src/Asset/Controller/Data/CustomSettingsController.php index 8f09c080..15b396d0 100644 --- a/src/Asset/Controller/Data/CustomSettingsController.php +++ b/src/Asset/Controller/Data/CustomSettingsController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/assets/{id}/custom-settings', name: 'pimcore_studio_api_get_asset_custom_settings', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[GET( - path: self::API_PATH . '/assets/{id}/custom-settings', + path: self::PREFIX . '/assets/{id}/custom-settings', operationId: 'asset_custom_settings_get_by_id', description: 'asset_custom_settings_get_by_id_description', summary: 'asset_custom_settings_get_by_id_summary', diff --git a/src/Asset/Controller/Data/TextController.php b/src/Asset/Controller/Data/TextController.php index daac1c43..9d5278c8 100644 --- a/src/Asset/Controller/Data/TextController.php +++ b/src/Asset/Controller/Data/TextController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/assets/{id}/text', name: 'pimcore_studio_api_get_asset_data_text', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/text', + path: self::PREFIX . '/assets/{id}/text', operationId: 'asset_get_text_data_by_id', description: 'asset_get_text_data_by_id_description', summary: 'asset_get_text_data_by_id_summary', diff --git a/src/Asset/Controller/Document/PreviewStreamController.php b/src/Asset/Controller/Document/PreviewStreamController.php index a7385706..3c91ec50 100644 --- a/src/Asset/Controller/Document/PreviewStreamController.php +++ b/src/Asset/Controller/Document/PreviewStreamController.php @@ -73,7 +73,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/document/stream/pdf-preview', + path: self::PREFIX . '/assets/{id}/document/stream/pdf-preview', operationId: 'asset_document_stream_preview', description: 'asset_document_stream_preview_description', summary: 'asset_document_stream_preview_summary', diff --git a/src/Asset/Controller/Download/CreateCsvController.php b/src/Asset/Controller/Download/CreateCsvController.php index 26d15a3a..5cfd9c67 100644 --- a/src/Asset/Controller/Download/CreateCsvController.php +++ b/src/Asset/Controller/Download/CreateCsvController.php @@ -48,7 +48,7 @@ public function __construct( #[Route('/assets/csv/create', name: 'pimcore_studio_api_create_csv_asset', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/csv/create', + path: self::PREFIX . '/assets/csv/create', operationId: 'asset_create_csv', description: 'asset_create_csv_description', summary: 'asset_create_csv_summary', diff --git a/src/Asset/Controller/Download/CreateZipController.php b/src/Asset/Controller/Download/CreateZipController.php index df53ce21..2fb624e8 100644 --- a/src/Asset/Controller/Download/CreateZipController.php +++ b/src/Asset/Controller/Download/CreateZipController.php @@ -58,7 +58,7 @@ public function __construct( #[Route('/assets/zip/create', name: 'pimcore_studio_api_create_zip_asset', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/zip/create', + path: self::PREFIX . '/assets/zip/create', operationId: 'asset_create_zip', description: 'asset_create_zip_description', summary: 'asset_create_zip_summary', diff --git a/src/Asset/Controller/Download/DeleteCsvController.php b/src/Asset/Controller/Download/DeleteCsvController.php index d7c43741..36712936 100644 --- a/src/Asset/Controller/Download/DeleteCsvController.php +++ b/src/Asset/Controller/Download/DeleteCsvController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/assets/download/csv/{jobRunId}', name: 'pimcore_studio_api_csv_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Delete( - path: self::API_PATH . '/assets/download/csv/{jobRunId}', + path: self::PREFIX . '/assets/download/csv/{jobRunId}', operationId: 'asset_delete_csv', description: 'asset_delete_csv_description', summary: 'asset_delete_csv_summary', diff --git a/src/Asset/Controller/Download/DeleteZipController.php b/src/Asset/Controller/Download/DeleteZipController.php index b5edc70e..7c728209 100644 --- a/src/Asset/Controller/Download/DeleteZipController.php +++ b/src/Asset/Controller/Download/DeleteZipController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/assets/download/zip/{jobRunId}', name: 'pimcore_studio_api_zip_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Delete( - path: self::API_PATH . '/assets/download/zip/{jobRunId}', + path: self::PREFIX . '/assets/download/zip/{jobRunId}', operationId: 'asset_delete_zip', description: 'asset_delete_zip_description', summary: 'asset_delete_zip_summary', diff --git a/src/Asset/Controller/Download/DownloadCsvController.php b/src/Asset/Controller/Download/DownloadCsvController.php index 2eb0d433..43a3b01a 100644 --- a/src/Asset/Controller/Download/DownloadCsvController.php +++ b/src/Asset/Controller/Download/DownloadCsvController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/assets/download/csv/{jobRunId}', name: 'pimcore_studio_api_csv_download_asset', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/download/csv/{jobRunId}', + path: self::PREFIX . '/assets/download/csv/{jobRunId}', operationId: 'asset_download_csv', description: 'asset_download_csv_description', summary: 'asset_download_csv_summary', diff --git a/src/Asset/Controller/Download/DownloadZipController.php b/src/Asset/Controller/Download/DownloadZipController.php index 93f24d5d..f2cccb8b 100644 --- a/src/Asset/Controller/Download/DownloadZipController.php +++ b/src/Asset/Controller/Download/DownloadZipController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/assets/download/zip/{jobRunId}', name: 'pimcore_studio_api_zip_download_asset', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/download/zip/{jobRunId}', + path: self::PREFIX . '/assets/download/zip/{jobRunId}', operationId: 'asset_download_zip', description: 'asset_download_zip_description', summary: 'asset_download_zip_summary', diff --git a/src/Asset/Controller/DownloadController.php b/src/Asset/Controller/DownloadController.php index 65ad912f..0c340010 100644 --- a/src/Asset/Controller/DownloadController.php +++ b/src/Asset/Controller/DownloadController.php @@ -64,7 +64,7 @@ public function __construct( #[Route('/assets/{id}/download', name: 'pimcore_studio_api_download_asset', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/download', + path: self::PREFIX . '/assets/{id}/download', operationId: 'asset_download_by_id', description: 'asset_download_by_id_description', summary: 'asset_download_by_id_summary', diff --git a/src/Asset/Controller/GetController.php b/src/Asset/Controller/GetController.php index 9ec855b8..e1601d5b 100644 --- a/src/Asset/Controller/GetController.php +++ b/src/Asset/Controller/GetController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/assets/{id}', name: 'pimcore_studio_api_get_asset', requirements: ['id' => '\d+'], methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}', + path: self::PREFIX . '/assets/{id}', operationId: 'asset_get_by_id', description: 'asset_get_by_id_description', summary: 'asset_get_by_id_summary', diff --git a/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php b/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php index 5fc65b6a..41ed6747 100644 --- a/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php +++ b/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php @@ -57,7 +57,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/grid/available-columns', + path: self::PREFIX . '/assets/grid/available-columns', operationId: 'asset_get_available_grid_columns', description: 'asset_get_available_grid_columns_description', summary: 'asset_get_available_grid_columns_summary', diff --git a/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php b/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php index 2388fab6..39df175c 100644 --- a/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php +++ b/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php @@ -59,7 +59,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/grid/configuration/{folderId}', + path: self::PREFIX . '/assets/grid/configuration/{folderId}', operationId: 'asset_get_grid_configuration_by_folderId', description: 'asset_get_grid_configuration_by_folderId_description', summary: 'asset_get_grid_configuration_by_folderId_summary', diff --git a/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php b/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php index fdaa5ca9..33abb845 100644 --- a/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php +++ b/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php @@ -57,7 +57,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/grid/configurations/{folderId}', + path: self::PREFIX . '/assets/grid/configurations/{folderId}', operationId: 'asset_get_saved_grid_configurations', description: 'asset_get_saved_grid_configurations_description', summary: 'asset_get_saved_grid_configurations_summary', diff --git a/src/Asset/Controller/Grid/Configuration/SaveConfigurationController.php b/src/Asset/Controller/Grid/Configuration/SaveConfigurationController.php index 2d0d58c1..d2f747f9 100644 --- a/src/Asset/Controller/Grid/Configuration/SaveConfigurationController.php +++ b/src/Asset/Controller/Grid/Configuration/SaveConfigurationController.php @@ -55,7 +55,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/grid/configuration/save', + path: self::PREFIX . '/assets/grid/configuration/save', operationId: 'asset_save_grid_configuration', description: 'asset_save_grid_configuration_description', summary: 'asset_save_grid_configuration_description', diff --git a/src/Asset/Controller/Grid/Configuration/SetAsFavoriteController.php b/src/Asset/Controller/Grid/Configuration/SetAsFavoriteController.php index 2ff3eb60..f834d3a9 100644 --- a/src/Asset/Controller/Grid/Configuration/SetAsFavoriteController.php +++ b/src/Asset/Controller/Grid/Configuration/SetAsFavoriteController.php @@ -55,7 +55,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/grid/configuration/set-as-favorite/{configurationId}/{folderId}', + path: self::PREFIX . '/assets/grid/configuration/set-as-favorite/{configurationId}/{folderId}', operationId: 'asset_set_grid_configuration_as_favorite', description: 'asset_set_grid_configuration_as_favorite_description', summary: 'asset_set_grid_configuration_as_favorite_summary', diff --git a/src/Asset/Controller/Grid/Configuration/UpdateConfigurationController.php b/src/Asset/Controller/Grid/Configuration/UpdateConfigurationController.php index 7723b470..31d3f3f7 100644 --- a/src/Asset/Controller/Grid/Configuration/UpdateConfigurationController.php +++ b/src/Asset/Controller/Grid/Configuration/UpdateConfigurationController.php @@ -56,7 +56,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Put( - path: self::API_PATH . '/assets/grid/configuration/update/{configurationId}', + path: self::PREFIX . '/assets/grid/configuration/update/{configurationId}', operationId: 'asset_update_grid_configuration', description: 'asset_update_grid_configuration_description', summary: 'asset_update_grid_configuration_summary', diff --git a/src/Asset/Controller/Grid/GetController.php b/src/Asset/Controller/Grid/GetController.php index 4d174c89..639873f1 100644 --- a/src/Asset/Controller/Grid/GetController.php +++ b/src/Asset/Controller/Grid/GetController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/assets/grid', name: 'pimcore_studio_api_get_asset_grid', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/grid', + path: self::PREFIX . '/assets/grid', operationId: 'asset_get_grid', description: 'asset_get_grid_description', summary: 'asset_get_grid_summary', diff --git a/src/Asset/Controller/Image/CustomDownloadController.php b/src/Asset/Controller/Image/CustomDownloadController.php index 3975e0cf..81e71ab5 100644 --- a/src/Asset/Controller/Image/CustomDownloadController.php +++ b/src/Asset/Controller/Image/CustomDownloadController.php @@ -72,7 +72,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/image/download/custom', + path: self::PREFIX . '/assets/{id}/image/download/custom', operationId: 'asset_image_download_custom', description: 'asset_image_download_custom_description', summary: 'asset_image_download_custom_summary', diff --git a/src/Asset/Controller/Image/FormatDownloadController.php b/src/Asset/Controller/Image/FormatDownloadController.php index e0e3cc21..892a2417 100644 --- a/src/Asset/Controller/Image/FormatDownloadController.php +++ b/src/Asset/Controller/Image/FormatDownloadController.php @@ -72,7 +72,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/image/download/format/{format}', + path: self::PREFIX . '/assets/{id}/image/download/format/{format}', operationId: 'asset_image_download_by_format', description: 'asset_image_download_by_format_description', summary: 'asset_image_download_by_format_summary', diff --git a/src/Asset/Controller/Image/ThumbnailDownloadController.php b/src/Asset/Controller/Image/ThumbnailDownloadController.php index 49a085ed..33fec52a 100644 --- a/src/Asset/Controller/Image/ThumbnailDownloadController.php +++ b/src/Asset/Controller/Image/ThumbnailDownloadController.php @@ -68,7 +68,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/image/download/thumbnail/{thumbnailName}', + path: self::PREFIX . '/assets/{id}/image/download/thumbnail/{thumbnailName}', operationId: 'asset_image_download_by_thumbnail', description: 'asset_image_download_by_thumbnail_description', summary: 'asset_image_download_by_thumbnail_summary', diff --git a/src/Asset/Controller/PatchController.php b/src/Asset/Controller/PatchController.php index 78ec46ea..21a33734 100644 --- a/src/Asset/Controller/PatchController.php +++ b/src/Asset/Controller/PatchController.php @@ -61,7 +61,7 @@ public function __construct( #[Route('/assets', name: 'pimcore_studio_api_patch_asset', methods: ['PATCH'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Patch( - path: self::API_PATH . '/assets', + path: self::PREFIX . '/assets', operationId: 'asset_patch_by_id', description: 'asset_patch_by_id_description', summary: 'asset_patch_by_id_summary', diff --git a/src/Asset/Controller/TreeController.php b/src/Asset/Controller/TreeController.php index c5b5a3d3..a0fb4728 100644 --- a/src/Asset/Controller/TreeController.php +++ b/src/Asset/Controller/TreeController.php @@ -66,7 +66,7 @@ public function __construct( #[Route('/assets/tree', name: 'pimcore_studio_api_assets_tree', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/tree', + path: self::PREFIX . '/assets/tree', operationId: 'asset_get_tree', description: 'asset_get_tree_description', summary: 'asset_get_tree_summary', diff --git a/src/Asset/Controller/UpdateController.php b/src/Asset/Controller/UpdateController.php index c5b93b7b..7292292a 100644 --- a/src/Asset/Controller/UpdateController.php +++ b/src/Asset/Controller/UpdateController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/assets/{id}', name: 'pimcore_studio_api_update_asset', methods: ['PUT'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Put( - path: self::API_PATH . '/assets/{id}', + path: self::PREFIX . '/assets/{id}', operationId: 'asset_update_by_id', description: 'asset_update_by_id_description', summary: 'asset_update_by_id_summary', diff --git a/src/Asset/Controller/Upload/AddController.php b/src/Asset/Controller/Upload/AddController.php index 92257dab..3a908348 100644 --- a/src/Asset/Controller/Upload/AddController.php +++ b/src/Asset/Controller/Upload/AddController.php @@ -69,7 +69,7 @@ public function __construct( #[Route('/assets/add/{parentId}', name: 'pimcore_studio_api_assets_add', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/add/{parentId}', + path: self::PREFIX . '/assets/add/{parentId}', operationId: 'asset_add', description: 'asset_add_description', summary: 'asset_add_summary', diff --git a/src/Asset/Controller/Upload/InfoController.php b/src/Asset/Controller/Upload/InfoController.php index ced3d063..4da632c3 100644 --- a/src/Asset/Controller/Upload/InfoController.php +++ b/src/Asset/Controller/Upload/InfoController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/assets/exists/{parentId}', name: 'pimcore_studio_api_asset_upload_info', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/exists/{parentId}', + path: self::PREFIX . '/assets/exists/{parentId}', operationId: 'asset_upload_info', description: 'asset_upload_info_description', summary: 'asset_upload_info_summary', diff --git a/src/Asset/Controller/Upload/ReplaceController.php b/src/Asset/Controller/Upload/ReplaceController.php index dce160c0..aae41c7d 100644 --- a/src/Asset/Controller/Upload/ReplaceController.php +++ b/src/Asset/Controller/Upload/ReplaceController.php @@ -67,7 +67,7 @@ public function __construct( #[Route('/assets/{id}/replace', name: 'pimcore_studio_api_assets_replace', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/{id}/replace', + path: self::PREFIX . '/assets/{id}/replace', operationId: 'asset_replace', description: 'asset_replace_description', summary: 'asset_replace_summary', diff --git a/src/Asset/Controller/Upload/ZipController.php b/src/Asset/Controller/Upload/ZipController.php index 1e6c7f4f..687b3aff 100644 --- a/src/Asset/Controller/Upload/ZipController.php +++ b/src/Asset/Controller/Upload/ZipController.php @@ -67,7 +67,7 @@ public function __construct( #[Route('/assets/add-zip/{parentId}', name: 'pimcore_studio_api_assets_upload_zip', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/assets/add-zip/{parentId}', + path: self::PREFIX . '/assets/add-zip/{parentId}', operationId: 'asset_upload_zip', description: 'asset_upload_zip_description', summary: 'asset_upload_zip_summary', diff --git a/src/Asset/Controller/Video/ImageThumbnailStreamController.php b/src/Asset/Controller/Video/ImageThumbnailStreamController.php index 16f6e4b2..d66b5213 100644 --- a/src/Asset/Controller/Video/ImageThumbnailStreamController.php +++ b/src/Asset/Controller/Video/ImageThumbnailStreamController.php @@ -77,7 +77,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/video/stream/image-thumbnail', + path: self::PREFIX . '/assets/{id}/video/stream/image-thumbnail', operationId: 'asset_video_image_thumbnail_stream', description: 'asset_video_image_thumbnail_stream_description', summary: 'asset_video_image_thumbnail_stream_summary', diff --git a/src/Asset/Controller/Video/ThumbnailDownloadController.php b/src/Asset/Controller/Video/ThumbnailDownloadController.php index 8dfc2e96..d1c83b60 100644 --- a/src/Asset/Controller/Video/ThumbnailDownloadController.php +++ b/src/Asset/Controller/Video/ThumbnailDownloadController.php @@ -72,7 +72,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/video/download/{thumbnailName}', + path: self::PREFIX . '/assets/{id}/video/download/{thumbnailName}', operationId: 'asset_video_download_by_thumbnail', description: 'asset_video_download_by_thumbnail_description', summary: 'asset_video_download_by_thumbnail_summary', diff --git a/src/Asset/Controller/Video/ThumbnailStreamController.php b/src/Asset/Controller/Video/ThumbnailStreamController.php index cc3ad961..7174be7f 100644 --- a/src/Asset/Controller/Video/ThumbnailStreamController.php +++ b/src/Asset/Controller/Video/ThumbnailStreamController.php @@ -72,7 +72,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/assets/{id}/video/stream/{thumbnailName}', + path: self::PREFIX . '/assets/{id}/video/stream/{thumbnailName}', operationId: 'asset_video_stream_by_thumbnail', description: 'asset_video_stream_by_thumbnail_description', summary: 'asset_video_stream_by_thumbnail_summary', diff --git a/src/Authorization/Controller/LoginController.php b/src/Authorization/Controller/LoginController.php index f8a7c272..371cf564 100644 --- a/src/Authorization/Controller/LoginController.php +++ b/src/Authorization/Controller/LoginController.php @@ -37,7 +37,7 @@ final class LoginController extends AbstractApiController { #[Route('/login', name: 'pimcore_studio_api_login', methods: ['POST'])] #[Post( - path: self::API_PATH . '/login', + path: self::PREFIX . '/login', operationId: 'login', description: 'login_description', summary: 'login_summary', diff --git a/src/Authorization/Controller/LogoutController.php b/src/Authorization/Controller/LogoutController.php index f4438f02..defd6353 100644 --- a/src/Authorization/Controller/LogoutController.php +++ b/src/Authorization/Controller/LogoutController.php @@ -30,7 +30,7 @@ final class LogoutController extends AbstractApiController { #[Route('/logout', name: 'pimcore_studio_api_logout', methods: ['POST'])] #[Post( - path: self::API_PATH . '/logout', + path: self::PREFIX . '/logout', operationId: 'logout', description: 'logout_description', summary: 'logout_summary', diff --git a/src/Controller/AbstractApiController.php b/src/Controller/AbstractApiController.php index 5f8053eb..6ffd02ec 100644 --- a/src/Controller/AbstractApiController.php +++ b/src/Controller/AbstractApiController.php @@ -20,22 +20,17 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; -/** - * @internal - */ -#[Route('/studio/api')] abstract class AbstractApiController extends AbstractController { public const VOTER_PUBLIC_STUDIO_API = 'PUBLIC_STUDIO_API'; - public const API_PATH = '/studio/api'; - - public function __construct(protected readonly SerializerInterface $serializer) - { + public const PREFIX = '{prefix}'; + public function __construct( + protected readonly SerializerInterface $serializer, + ) { } protected function jsonResponse( diff --git a/src/DataObject/Controller/AddController.php b/src/DataObject/Controller/AddController.php index af7b1009..eeb62ca4 100644 --- a/src/DataObject/Controller/AddController.php +++ b/src/DataObject/Controller/AddController.php @@ -64,7 +64,7 @@ public function __construct( #[Route('/data-objects/add/{parentId}', name: 'pimcore_studio_api_data_objects_add', methods: ['POST'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Post( - path: self::API_PATH . '/data-objects/add/{parentId}', + path: self::PREFIX . '/data-objects/add/{parentId}', operationId: 'data_object_add', description: 'data_object_add_description', summary: 'data_object_add_summary', diff --git a/src/DataObject/Controller/CloneController.php b/src/DataObject/Controller/CloneController.php index 5ffd8ee9..4bb6d62e 100644 --- a/src/DataObject/Controller/CloneController.php +++ b/src/DataObject/Controller/CloneController.php @@ -63,7 +63,7 @@ public function __construct( #[Route('/data-objects/{id}/clone/{parentId}', name: 'pimcore_studio_api_data_objects_clone', methods: ['POST'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Post( - path: self::API_PATH . '/data-objects/{id}/clone/{parentId}', + path: self::PREFIX . '/data-objects/{id}/clone/{parentId}', operationId: 'data_object_clone', description: 'data_object_clone_description', summary: 'data_object_clone_summary', diff --git a/src/DataObject/Controller/GetController.php b/src/DataObject/Controller/GetController.php index 5e010400..33f0ec34 100644 --- a/src/DataObject/Controller/GetController.php +++ b/src/DataObject/Controller/GetController.php @@ -51,7 +51,7 @@ public function __construct( )] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Get( - path: self::API_PATH . '/data-objects/{id}', + path: self::PREFIX . '/data-objects/{id}', operationId: 'data_object_get_by_id', description: 'data_object_get_by_id_description', summary: 'data_object_get_by_id_summary', diff --git a/src/DataObject/Controller/Grid/GetAvailableColumnsController.php b/src/DataObject/Controller/Grid/GetAvailableColumnsController.php index a9677834..2855d17f 100644 --- a/src/DataObject/Controller/Grid/GetAvailableColumnsController.php +++ b/src/DataObject/Controller/Grid/GetAvailableColumnsController.php @@ -59,7 +59,7 @@ public function __construct( )] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Get( - path: self::API_PATH . '/data-object/grid/available-columns/{classId}/folderId', + path: self::PREFIX . '/data-object/grid/available-columns/{classId}/folderId', operationId: 'data_object_get_available_grid_columns', description: 'data_object_get_available_grid_columns_description', summary: 'data_object_get_available_grid_columns_summary', diff --git a/src/DataObject/Controller/Grid/GetController.php b/src/DataObject/Controller/Grid/GetController.php index 59bc472a..629c6448 100644 --- a/src/DataObject/Controller/Grid/GetController.php +++ b/src/DataObject/Controller/Grid/GetController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/data-objects/grid', name: 'pimcore_studio_api_get_data_object_grid', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/data-objects/grid', + path: self::PREFIX . '/data-objects/grid', operationId: 'data_object_get_grid', description: 'data_object_get_grid_description', summary: 'data_object_get_grid_summary', diff --git a/src/DataObject/Controller/PatchController.php b/src/DataObject/Controller/PatchController.php index 393a3c26..4b6a4592 100644 --- a/src/DataObject/Controller/PatchController.php +++ b/src/DataObject/Controller/PatchController.php @@ -61,7 +61,7 @@ public function __construct( #[Route('/data-objects', name: 'pimcore_studio_api_patch_data_object', methods: ['PATCH'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Patch( - path: self::API_PATH . '/data-objects', + path: self::PREFIX . '/data-objects', operationId: 'data_object_patch_by_id', description: 'data_object_patch_by_id_description', summary: 'data_object_patch_by_id_summary', diff --git a/src/DataObject/Controller/ReplaceController.php b/src/DataObject/Controller/ReplaceController.php index 1d3b74ff..6bdb351d 100644 --- a/src/DataObject/Controller/ReplaceController.php +++ b/src/DataObject/Controller/ReplaceController.php @@ -62,7 +62,7 @@ public function __construct( )] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Post( - path: self::API_PATH . '/data-objects/{sourceId}/replace/{targetId}', + path: self::PREFIX . '/data-objects/{sourceId}/replace/{targetId}', operationId: 'data_object_replace_content', description: 'data_object_replace_content_description', summary: 'data_object_replace_content_summary', diff --git a/src/DataObject/Controller/TreeController.php b/src/DataObject/Controller/TreeController.php index 6279c83c..cda52da8 100644 --- a/src/DataObject/Controller/TreeController.php +++ b/src/DataObject/Controller/TreeController.php @@ -68,7 +68,7 @@ public function __construct( #[Route('/data-objects/tree', name: 'pimcore_studio_api_data_objects_tree', methods: ['GET'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Get( - path: self::API_PATH . '/data-objects/tree', + path: self::PREFIX . '/data-objects/tree', operationId: 'data_object_get_tree', description: 'data_object_get_tree_description', summary: 'data_object_get_tree_summary', diff --git a/src/DataObject/Controller/UpdateController.php b/src/DataObject/Controller/UpdateController.php index 8802fe54..5fbb281c 100644 --- a/src/DataObject/Controller/UpdateController.php +++ b/src/DataObject/Controller/UpdateController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/data-objects/{id}', name: 'pimcore_studio_api_update_data_object', methods: ['PUT'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Put( - path: self::API_PATH . '/data-objects/{id}', + path: self::PREFIX . '/data-objects/{id}', operationId: 'data_object_update_by_id', description: 'data_object_update_by_id_description', summary: 'data_object_update_by_id_summary', diff --git a/src/Dependency/Controller/Element/CollectionController.php b/src/Dependency/Controller/Element/CollectionController.php index ee52a941..3dc66337 100644 --- a/src/Dependency/Controller/Element/CollectionController.php +++ b/src/Dependency/Controller/Element/CollectionController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/dependencies/{elementType}/{id}', name: 'pimcore_studio_api_dependencies', methods: ['GET'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/dependencies/{elementType}/{id}', + path: self::PREFIX . '/dependencies/{elementType}/{id}', operationId: 'dependency_get_collection_by_element_type', description: 'Get paginated dependencies. Pass dependency mode to get either all elements that depend on the provided element diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 68fb29e5..2dd735a3 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -44,6 +44,7 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $treeBuilder->getRootNode(); $rootNode->addDefaultsIfNotSet(); + $this->addUrlPrefix($rootNode); $this->addOpenApiScanPathsNode($rootNode); $this->addApiTokenNode($rootNode); $this->addAllowedHostsForCorsNode($rootNode); @@ -59,6 +60,14 @@ public function getConfigTreeBuilder(): TreeBuilder return $treeBuilder; } + private function addUrlPrefix(ArrayNodeDefinition $node): void + { + $node->children() + ->scalarNode('url_prefix') + ->defaultValue('/pimcore-studio/api') + ->end(); + } + private function addOpenApiScanPathsNode(ArrayNodeDefinition $node): void { $node->children() diff --git a/src/DependencyInjection/PimcoreStudioBackendExtension.php b/src/DependencyInjection/PimcoreStudioBackendExtension.php index b81258a8..0d2bc3ed 100644 --- a/src/DependencyInjection/PimcoreStudioBackendExtension.php +++ b/src/DependencyInjection/PimcoreStudioBackendExtension.php @@ -67,6 +67,7 @@ public function load(array $configs, ContainerBuilder $container): void $this->checkValidOpenApiScanPaths($config['open_api_scan_paths']); $definition = $container->getDefinition(OpenApiServiceInterface::class); + $definition->setArgument('$routePrefix', rtrim($config['url_prefix'], '/')); $definition->setArgument('$openApiScanPaths', $config['open_api_scan_paths']); $definition = $container->getDefinition(CorsSubscriber::class); @@ -92,17 +93,20 @@ public function load(array $configs, ContainerBuilder $container): void $definition = $container->getDefinition(NoteServiceInterface::class); $definition->setArgument('$noteTypes', $config['notes']['types']); - } public function prepend(ContainerBuilder $container): void { + if (!$container->hasParameter('pimcore_studio_backend.firewall_settings')) { $containerConfig = ConfigurationHelper::getConfigNodeFromSymfonyTree($container, 'pimcore_studio_backend'); $container->setParameter('pimcore_studio_backend.firewall_settings', $containerConfig['security_firewall']); } $containerConfig = ConfigurationHelper::getConfigNodeFromSymfonyTree($container, 'pimcore_studio_backend'); + + $container->setParameter('pimcore_studio_backend.url_prefix', rtrim($containerConfig['url_prefix'], '/')); + foreach ($containerConfig['mercure_settings'] as $key => $setting) { if ($container->hasParameter('pimcore_studio_backend.mercure_settings.' . $key)) { continue; diff --git a/src/Element/Controller/DeleteController.php b/src/Element/Controller/DeleteController.php index c226a729..f55f9c72 100644 --- a/src/Element/Controller/DeleteController.php +++ b/src/Element/Controller/DeleteController.php @@ -67,7 +67,7 @@ public function __construct( #[Route('/elements/{elementType}/delete/{id}', name: 'pimcore_studio_api_elements_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Delete( - path: self::API_PATH . '/elements/{elementType}/delete/{id}', + path: self::PREFIX . '/elements/{elementType}/delete/{id}', operationId: 'element_delete', description: 'element_delete_description', summary: 'element_delete_summary', diff --git a/src/Element/Controller/DeleteInfoController.php b/src/Element/Controller/DeleteInfoController.php index ca05741e..e2d9af38 100644 --- a/src/Element/Controller/DeleteInfoController.php +++ b/src/Element/Controller/DeleteInfoController.php @@ -57,7 +57,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/elements/{elementType}/delete-info/{id}', + path: self::PREFIX . '/elements/{elementType}/delete-info/{id}', operationId: 'element_get_delete_info', description: 'element_get_delete_info_description', summary: 'element_get_delete_info_summary', diff --git a/src/Element/Controller/FolderController.php b/src/Element/Controller/FolderController.php index 46a846cc..2fcbb911 100644 --- a/src/Element/Controller/FolderController.php +++ b/src/Element/Controller/FolderController.php @@ -68,7 +68,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Post( - path: self::API_PATH . '/elements/{elementType}/folder/{parentId}', + path: self::PREFIX . '/elements/{elementType}/folder/{parentId}', operationId: 'element_folder_create', description: 'element_folder_create_description', summary: 'element_folder_create_summary', diff --git a/src/Element/Controller/GetIdByPathController.php b/src/Element/Controller/GetIdByPathController.php index 14b71de5..97aa6ef9 100644 --- a/src/Element/Controller/GetIdByPathController.php +++ b/src/Element/Controller/GetIdByPathController.php @@ -56,7 +56,7 @@ public function __construct( )] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/elements/{elementType}/path', + path: self::PREFIX . '/elements/{elementType}/path', operationId: 'element_get_id_by_path', description: 'element_get_id_by_path_description', summary: 'element_get_id_by_path_summary', diff --git a/src/Email/Controller/Blocklist/AddController.php b/src/Email/Controller/Blocklist/AddController.php index 51c6b1f7..0f026c2a 100644 --- a/src/Email/Controller/Blocklist/AddController.php +++ b/src/Email/Controller/Blocklist/AddController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/emails/blocklist', name: 'pimcore_studio_api_emails_blocklist_add', methods: ['POST'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Post( - path: self::API_PATH . '/emails/blocklist', + path: self::PREFIX . '/emails/blocklist', operationId: 'email_blocklist_add', description: 'email_blocklist_add_description', summary: 'email_blocklist_add_summary', diff --git a/src/Email/Controller/Blocklist/CollectionController.php b/src/Email/Controller/Blocklist/CollectionController.php index 98161c0e..f8ad52ac 100644 --- a/src/Email/Controller/Blocklist/CollectionController.php +++ b/src/Email/Controller/Blocklist/CollectionController.php @@ -60,7 +60,7 @@ public function __construct( #[Route('/emails/blocklist', name: 'pimcore_studio_api_emails_blocklist_list', methods: ['GET'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Get( - path: self::API_PATH . '/emails/blocklist', + path: self::PREFIX . '/emails/blocklist', operationId: 'email_blocklist_get_collection', description: 'email_blocklist_get_collection_description', summary: 'email_blocklist_get_collection_summary', diff --git a/src/Email/Controller/Blocklist/DeleteController.php b/src/Email/Controller/Blocklist/DeleteController.php index 6e9f2059..f76cd71e 100644 --- a/src/Email/Controller/Blocklist/DeleteController.php +++ b/src/Email/Controller/Blocklist/DeleteController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/emails/blocklist', name: 'pimcore_studio_api_emails_blocklist_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Delete( - path: self::API_PATH . '/emails/blocklist', + path: self::PREFIX . '/emails/blocklist', operationId: 'email_blocklist_delete', description: 'email_blocklist_delete_description', summary: 'email_blocklist_delete_summary', diff --git a/src/Email/Controller/CollectionController.php b/src/Email/Controller/CollectionController.php index 50be8ecd..5e56a986 100644 --- a/src/Email/Controller/CollectionController.php +++ b/src/Email/Controller/CollectionController.php @@ -59,7 +59,7 @@ public function __construct( #[IsGranted(UserPermissions::EMAILS->value)] #[IsGranted(UserPermissions::GDPR->value)] #[Get( - path: self::API_PATH . '/emails', + path: self::PREFIX . '/emails', operationId: 'email_log_get_collection', description: 'email_log_get_collection_description', summary: 'email_log_get_collection_summary', diff --git a/src/Email/Controller/DeleteController.php b/src/Email/Controller/DeleteController.php index 0f2db17d..b2036c16 100644 --- a/src/Email/Controller/DeleteController.php +++ b/src/Email/Controller/DeleteController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/emails/{id}', name: 'pimcore_studio_api_emails_list_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Delete( - path: self::API_PATH . '/emails/{id}', + path: self::PREFIX . '/emails/{id}', operationId: 'email_log_delete', description: 'email_log_delete_description', summary: 'email_log_delete_summary', diff --git a/src/Email/Controller/Detail/EmailHtmlController.php b/src/Email/Controller/Detail/EmailHtmlController.php index 72d07285..10e3efbb 100644 --- a/src/Email/Controller/Detail/EmailHtmlController.php +++ b/src/Email/Controller/Detail/EmailHtmlController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/emails/{id}/html', name: 'pimcore_studio_api_emails_log_html', methods: ['GET'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Get( - path: self::API_PATH . '/emails/{id}/html', + path: self::PREFIX . '/emails/{id}/html', operationId: 'email_log_get_html', description: 'email_log_get_html_description', summary: 'email_log_get_html_summary', diff --git a/src/Email/Controller/Detail/EmailParamsController.php b/src/Email/Controller/Detail/EmailParamsController.php index c27597d2..ca9bb926 100644 --- a/src/Email/Controller/Detail/EmailParamsController.php +++ b/src/Email/Controller/Detail/EmailParamsController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/emails/{id}/params', name: 'pimcore_studio_api_emails_log_params', methods: ['GET'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Get( - path: self::API_PATH . '/emails/{id}/params', + path: self::PREFIX . '/emails/{id}/params', operationId: 'email_log_get_params', description: 'email_log_get_params_description', summary: 'email_log_get_params_summary', diff --git a/src/Email/Controller/Detail/EmailTextController.php b/src/Email/Controller/Detail/EmailTextController.php index caf639e3..4f2b7956 100644 --- a/src/Email/Controller/Detail/EmailTextController.php +++ b/src/Email/Controller/Detail/EmailTextController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/emails/{id}/text', name: 'pimcore_studio_api_emails_log_text', methods: ['GET'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Get( - path: self::API_PATH . '/emails/{id}/text', + path: self::PREFIX . '/emails/{id}/text', operationId: 'email_log_get_text', description: 'email_log_get_text_description', summary: 'email_log_get_text_summary', diff --git a/src/Email/Controller/Detail/GetController.php b/src/Email/Controller/Detail/GetController.php index 1a32884a..1808b956 100644 --- a/src/Email/Controller/Detail/GetController.php +++ b/src/Email/Controller/Detail/GetController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/emails/{id}', name: 'pimcore_studio_api_emails_log_entry', methods: ['GET'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Get( - path: self::API_PATH . '/emails/{id}', + path: self::PREFIX . '/emails/{id}', operationId: 'email_log_get_by_id', description: 'email_log_get_by_id_description', summary: 'email_log_get_by_id_summary', diff --git a/src/Email/Controller/ForwardController.php b/src/Email/Controller/ForwardController.php index 613bb8a5..965ece06 100644 --- a/src/Email/Controller/ForwardController.php +++ b/src/Email/Controller/ForwardController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/emails/{id}/forward', name: 'pimcore_studio_api_emails_forward', methods: ['POST'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Post( - path: self::API_PATH . '/emails/{id}/forward', + path: self::PREFIX . '/emails/{id}/forward', operationId: 'email_log_forward_by_id', description: 'email_log_forward_by_id_description', summary: 'email_log_forward_by_id_summary', diff --git a/src/Email/Controller/ResendController.php b/src/Email/Controller/ResendController.php index 7df94bf8..e7da9464 100644 --- a/src/Email/Controller/ResendController.php +++ b/src/Email/Controller/ResendController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/emails/{id}/resend', name: 'pimcore_studio_api_emails_resend', methods: ['POST'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Post( - path: self::API_PATH . '/emails/{id}/resend', + path: self::PREFIX . '/emails/{id}/resend', operationId: 'email_log_resend_by_id', description: 'email_log_resend_by_id_description', summary: 'email_log_resend_by_id_summary', diff --git a/src/Email/Controller/TestEmailController.php b/src/Email/Controller/TestEmailController.php index 5e663fb0..bc67f926 100644 --- a/src/Email/Controller/TestEmailController.php +++ b/src/Email/Controller/TestEmailController.php @@ -61,7 +61,7 @@ public function __construct( #[Route('/emails/test', name: 'pimcore_studio_api_emails_test', methods: ['POST'])] #[IsGranted(UserPermissions::EMAILS->value)] #[Post( - path: self::API_PATH . '/emails/test', + path: self::PREFIX . '/emails/test', operationId: 'email_send_test', description: 'email_send_test_description', summary: 'email_send_test_summary', diff --git a/src/ExecutionEngine/Controller/AbortController.php b/src/ExecutionEngine/Controller/AbortController.php index 3cb9ab5c..62ff8d0d 100644 --- a/src/ExecutionEngine/Controller/AbortController.php +++ b/src/ExecutionEngine/Controller/AbortController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/execution-engine/abort/{jobRunId}', name: 'pimcore_studio_api_execution_engine_abort', methods: ['POST'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Post( - path: self::API_PATH . '/execution-engine/abort/{JobRunId}', + path: self::PREFIX . '/execution-engine/abort/{JobRunId}', operationId: 'execution_engine_abort_job_run_by_id', description: 'execution_engine_abort_job_run_by_id_description', summary: 'execution_engine_abort_job_run_by_id_summary', diff --git a/src/Mercure/Controller/JwtController.php b/src/Mercure/Controller/JwtController.php index 7c0c8dc7..f705e794 100644 --- a/src/Mercure/Controller/JwtController.php +++ b/src/Mercure/Controller/JwtController.php @@ -40,7 +40,7 @@ public function __construct( #[Route('/mercure/auth', name: 'pimcore_studio_mercure_auth', methods: ['POST'])] #[Post( - path: self::API_PATH . '/mercure/auth', + path: self::PREFIX . '/mercure/auth', operationId: 'mercure_create_cookie', description: 'mercure_create_cookie_description', summary: 'mercure_create_cookie_summary', diff --git a/src/Note/Controller/CollectionController.php b/src/Note/Controller/CollectionController.php index 8df7adc4..5b52339d 100644 --- a/src/Note/Controller/CollectionController.php +++ b/src/Note/Controller/CollectionController.php @@ -63,7 +63,7 @@ public function __construct( #[Route('/notes', name: 'pimcore_studio_api_get_notes', methods: ['GET'])] #[IsGranted(UserPermissions::NOTES_EVENTS->value)] #[Get( - path: self::API_PATH . '/notes', + path: self::PREFIX . '/notes', operationId: 'note_get_collection', description: 'note_get_collection_description', summary: 'note_get_collection_summary', diff --git a/src/Note/Controller/DeleteController.php b/src/Note/Controller/DeleteController.php index b6e861fa..fc997c09 100644 --- a/src/Note/Controller/DeleteController.php +++ b/src/Note/Controller/DeleteController.php @@ -49,7 +49,7 @@ public function __construct( #[Route('/notes/{id}', name: 'pimcore_studio_api_delete_note', methods: ['DELETE'])] #[IsGranted(UserPermissions::NOTES_EVENTS->value)] #[Delete( - path: self::API_PATH . '/notes/{id}', + path: self::PREFIX . '/notes/{id}', operationId: 'note_delete_by_id', description: 'note_delete_by_id_description', summary: 'note_delete_by_id_summary', diff --git a/src/Note/Controller/Element/CollectionController.php b/src/Note/Controller/Element/CollectionController.php index 91f16dc3..e8d23bc3 100644 --- a/src/Note/Controller/Element/CollectionController.php +++ b/src/Note/Controller/Element/CollectionController.php @@ -71,7 +71,7 @@ public function __construct( #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[IsGranted(UserPermissions::NOTES_EVENTS->value)] #[Get( - path: self::API_PATH . '/notes/{elementType}/{id}', + path: self::PREFIX . '/notes/{elementType}/{id}', operationId: 'note_element_get_collection', description: 'note_element_get_collection_description', summary: 'note_element_get_collection_summary', diff --git a/src/Note/Controller/Element/CreateController.php b/src/Note/Controller/Element/CreateController.php index e164682d..6bf8fdd7 100644 --- a/src/Note/Controller/Element/CreateController.php +++ b/src/Note/Controller/Element/CreateController.php @@ -59,7 +59,7 @@ public function __construct( #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[IsGranted(UserPermissions::NOTES_EVENTS->value)] #[Post( - path: self::API_PATH . '/notes/{elementType}/{id}', + path: self::PREFIX . '/notes/{elementType}/{id}', operationId: 'note_element_create', description: 'note_element_create_description', summary: 'note_element_create_summary', diff --git a/src/Note/Controller/Element/TypeController.php b/src/Note/Controller/Element/TypeController.php index 268f5637..084ad249 100644 --- a/src/Note/Controller/Element/TypeController.php +++ b/src/Note/Controller/Element/TypeController.php @@ -51,7 +51,7 @@ public function __construct( #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[IsGranted(UserPermissions::NOTES_EVENTS->value)] #[Get( - path: self::API_PATH . '/notes/type/{elementType}', + path: self::PREFIX . '/notes/type/{elementType}', operationId: 'note_element_get_type_collection', description: 'note_element_get_type_collection_description', summary: 'note_element_get_type_collection_summary', diff --git a/src/Notification/Controller/CollectionController.php b/src/Notification/Controller/CollectionController.php index 48d31bc5..ca7ba49b 100644 --- a/src/Notification/Controller/CollectionController.php +++ b/src/Notification/Controller/CollectionController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/notifications', name: 'pimcore_studio_api_notifications_list', methods: ['POST'])] #[IsGranted(UserPermissions::NOTIFICATIONS->value)] #[Post( - path: self::API_PATH . '/notifications', + path: self::PREFIX . '/notifications', operationId: 'notification_get_collection', description: 'notification_get_collection_description', summary: 'notification_get_collection_summary', diff --git a/src/Notification/Controller/DeleteAllController.php b/src/Notification/Controller/DeleteAllController.php index edeb4ec4..5e8fc5a2 100644 --- a/src/Notification/Controller/DeleteAllController.php +++ b/src/Notification/Controller/DeleteAllController.php @@ -48,7 +48,7 @@ public function __construct( #[Route('/notifications', name: 'pimcore_studio_api_delete_all_notifications', methods: ['DELETE'])] #[IsGranted(UserPermissions::NOTIFICATIONS->value)] #[Delete( - path: self::API_PATH . '/notifications', + path: self::PREFIX . '/notifications', operationId: 'notification_delete_all', description: 'notification_delete_all_description', summary: 'notification_delete_all_summary', diff --git a/src/Notification/Controller/DeleteController.php b/src/Notification/Controller/DeleteController.php index e15162f8..a6880b21 100644 --- a/src/Notification/Controller/DeleteController.php +++ b/src/Notification/Controller/DeleteController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/notifications/{id}', name: 'pimcore_studio_api_delete_notification', methods: ['DELETE'])] #[IsGranted(UserPermissions::NOTIFICATIONS->value)] #[Delete( - path: self::API_PATH . '/notifications/{id}', + path: self::PREFIX . '/notifications/{id}', operationId: 'notification_delete_by_id', description: 'notification_delete_by_id_description', summary: 'notification_delete_by_id_summary', diff --git a/src/Notification/Controller/GetController.php b/src/Notification/Controller/GetController.php index c6a4d5bd..3d78eacd 100644 --- a/src/Notification/Controller/GetController.php +++ b/src/Notification/Controller/GetController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/notifications/{id}', name: 'pimcore_studio_api_notification_get', methods: ['GET'])] #[IsGranted(UserPermissions::NOTIFICATIONS->value)] #[Get( - path: self::API_PATH . '/notifications/{id}', + path: self::PREFIX . '/notifications/{id}', operationId: 'notification_get_by_id', description: 'notification_get_by_id_description', summary: 'notification_get_by_id_summary', diff --git a/src/Notification/Controller/ReadController.php b/src/Notification/Controller/ReadController.php index d82d100d..9396a431 100644 --- a/src/Notification/Controller/ReadController.php +++ b/src/Notification/Controller/ReadController.php @@ -56,7 +56,7 @@ public function __construct( ] #[IsGranted(UserPermissions::NOTIFICATIONS->value)] #[POST( - path: self::API_PATH . '/notifications/{id}', + path: self::PREFIX . '/notifications/{id}', operationId: 'notification_read_by_id', description: 'notification_read_by_id_description', summary: 'notification_read_by_id_summary', diff --git a/src/Notification/Controller/SendController.php b/src/Notification/Controller/SendController.php index 90ffa376..4103d05b 100644 --- a/src/Notification/Controller/SendController.php +++ b/src/Notification/Controller/SendController.php @@ -61,7 +61,7 @@ public function __construct( #[Route('/notifications/send', name: 'pimcore_studio_api_notification_send', methods: ['POST'])] #[IsGranted(UserPermissions::NOTIFICATIONS_SEND->value)] #[Post( - path: self::API_PATH . '/notifications/send', + path: self::PREFIX . '/notifications/send', operationId: 'notification_send', description: 'notification_send_description', summary: 'notification_send_summary', diff --git a/src/OpenApi/Service/OpenApiService.php b/src/OpenApi/Service/OpenApiService.php index 7018339c..e3a27d17 100644 --- a/src/OpenApi/Service/OpenApiService.php +++ b/src/OpenApi/Service/OpenApiService.php @@ -18,6 +18,7 @@ use JsonException; use OpenApi\Annotations\OpenApi; +use OpenApi\Annotations\PathItem; use OpenApi\Attributes\Schema; use OpenApi\Generator; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\EnvironmentException; @@ -32,6 +33,7 @@ public function __construct( private TranslatorServiceInterface $translator, + private string $routePrefix, private array $openApiScanPaths = [] ) { } @@ -42,6 +44,17 @@ public function getConfig(): OpenApi if ($config) { usort($config->components->schemas, [$this, 'sortSchemas']); + + // replace the configurable prefix in the paths + $prefix = $this->routePrefix; + $config->paths = array_map( + static function (PathItem $pathItem) use ($prefix) { + $pathItem->path = str_replace('{prefix}', $prefix, $pathItem->path); + + return $pathItem; + }, + $config->paths + ); } return $config; diff --git a/src/Property/Controller/CollectionController.php b/src/Property/Controller/CollectionController.php index 1f1b26c1..f5aa8f23 100644 --- a/src/Property/Controller/CollectionController.php +++ b/src/Property/Controller/CollectionController.php @@ -50,7 +50,7 @@ public function __construct( #[Route('/properties', name: 'pimcore_studio_api_properties', methods: ['GET'])] #[Get( - path: self::API_PATH . '/properties', + path: self::PREFIX . '/properties', operationId: 'property_get_collection', description: 'property_get_collection_description', summary: 'property_get_collection_summary', diff --git a/src/Property/Controller/CreateController.php b/src/Property/Controller/CreateController.php index c95a7a1e..7d1cb698 100644 --- a/src/Property/Controller/CreateController.php +++ b/src/Property/Controller/CreateController.php @@ -50,7 +50,7 @@ public function __construct( #[Route('/property', name: 'pimcore_studio_api_property_create', methods: ['POST'])] #[IsGranted(UserPermissions::PREDEFINED_PROPERTIES->value)] #[POST( - path: self::API_PATH . '/property', + path: self::PREFIX . '/property', operationId: 'property_create', description: 'property_create_description', summary: 'property_create_summary', diff --git a/src/Property/Controller/DeleteController.php b/src/Property/Controller/DeleteController.php index 40327670..91dab6ee 100644 --- a/src/Property/Controller/DeleteController.php +++ b/src/Property/Controller/DeleteController.php @@ -50,7 +50,7 @@ public function __construct( #[Route('/properties/{id}', name: 'pimcore_studio_api_delete_properties', methods: ['DELETE'])] #[IsGranted(UserPermissions::PREDEFINED_PROPERTIES->value)] #[Delete( - path: self::API_PATH . '/properties/{id}', + path: self::PREFIX . '/properties/{id}', operationId: 'property_delete', description: 'property_delete_description', summary: 'property_delete_summary', diff --git a/src/Property/Controller/Element/CollectionController.php b/src/Property/Controller/Element/CollectionController.php index 6f35b229..fe634895 100644 --- a/src/Property/Controller/Element/CollectionController.php +++ b/src/Property/Controller/Element/CollectionController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/properties/{elementType}/{id}', name: 'pimcore_studio_api_get_element_properties', methods: ['GET'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/properties/{elementType}/{id}', + path: self::PREFIX . '/properties/{elementType}/{id}', operationId: 'property_get_collection_for_element_by_type_and_id', description: 'property_get_collection_for_element_by_type_and_id_description', summary: 'property_get_collection_for_element_by_type_and_id_summary', diff --git a/src/Property/Controller/UpdateController.php b/src/Property/Controller/UpdateController.php index 887a6f97..c5f008b1 100644 --- a/src/Property/Controller/UpdateController.php +++ b/src/Property/Controller/UpdateController.php @@ -55,7 +55,7 @@ public function __construct( #[Route('/properties/{id}', name: 'pimcore_studio_api_update_property', methods: ['PUT'])] #[IsGranted(UserPermissions::PREDEFINED_PROPERTIES->value)] #[Put( - path: self::API_PATH . '/properties/{id}', + path: self::PREFIX . '/properties/{id}', operationId: 'property_update', description: 'property_update_description', summary: 'property_update_summary', diff --git a/src/Role/Controller/CloneController.php b/src/Role/Controller/CloneController.php index 781a46fb..9d14d768 100644 --- a/src/Role/Controller/CloneController.php +++ b/src/Role/Controller/CloneController.php @@ -55,7 +55,7 @@ public function __construct( #[Route('/role/clone/{id}', name: 'pimcore_studio_api_role_clone', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/role/clone/{id}', + path: self::PREFIX . '/role/clone/{id}', operationId: 'role_clone_by_id', summary: 'role_clone_by_id_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/CreateFolderController.php b/src/Role/Controller/CreateFolderController.php index 902a44d5..7d9ac688 100644 --- a/src/Role/Controller/CreateFolderController.php +++ b/src/Role/Controller/CreateFolderController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/role/folder', name: 'pimcore_studio_api_role_folder_create', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/role/folder', + path: self::PREFIX . '/role/folder', operationId: 'role_folder_create', summary: 'role_folder_create_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/CreateRoleController.php b/src/Role/Controller/CreateRoleController.php index be1179ea..2a104e4f 100644 --- a/src/Role/Controller/CreateRoleController.php +++ b/src/Role/Controller/CreateRoleController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/role', name: 'pimcore_studio_api_role_create', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/role', + path: self::PREFIX . '/role', operationId: 'role_create', summary: 'role_create_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/DeleteFolderController.php b/src/Role/Controller/DeleteFolderController.php index 2a761949..e382172d 100644 --- a/src/Role/Controller/DeleteFolderController.php +++ b/src/Role/Controller/DeleteFolderController.php @@ -50,7 +50,7 @@ public function __construct( #[Route('/role/folder/{id}', name: 'pimcore_studio_api_role_folder_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Delete( - path: self::API_PATH . '/role/folder/{id}', + path: self::PREFIX . '/role/folder/{id}', operationId: 'role_folder_delete_by_id', summary: 'role_folder_delete_by_id_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/DeleteRoleController.php b/src/Role/Controller/DeleteRoleController.php index 2076217a..744d140c 100644 --- a/src/Role/Controller/DeleteRoleController.php +++ b/src/Role/Controller/DeleteRoleController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/role/{id}', name: 'pimcore_studio_api_role_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Delete( - path: self::API_PATH . '/role/{id}', + path: self::PREFIX . '/role/{id}', operationId: 'role_delete_by_id', summary: 'role_delete_by_id_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/GetRoleController.php b/src/Role/Controller/GetRoleController.php index 72cdcb40..2e9ecf81 100644 --- a/src/Role/Controller/GetRoleController.php +++ b/src/Role/Controller/GetRoleController.php @@ -55,7 +55,7 @@ public function __construct( #[Route('/role/{id}', name: 'pimcore_studio_api_role_get', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/role/{id}', + path: self::PREFIX . '/role/{id}', operationId: 'role_get_by_id', summary: 'role_get_by_id_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/GetRolesController.php b/src/Role/Controller/GetRolesController.php index 35afd883..4fe2e31b 100644 --- a/src/Role/Controller/GetRolesController.php +++ b/src/Role/Controller/GetRolesController.php @@ -49,7 +49,7 @@ public function __construct( #[Route('/roles', name: 'pimcore_studio_api_roles', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/roles', + path: self::PREFIX . '/roles', operationId: 'role_get_collection', description: 'role_get_collection_description', summary: 'role_get_collection_summary', diff --git a/src/Role/Controller/RoleTreeController.php b/src/Role/Controller/RoleTreeController.php index da512bb1..71a4d829 100644 --- a/src/Role/Controller/RoleTreeController.php +++ b/src/Role/Controller/RoleTreeController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/roles/tree', name: 'pimcore_studio_api_role_tree', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/roles/tree', + path: self::PREFIX . '/roles/tree', operationId: 'role_get_tree', summary: 'role_get_tree_summary', tags: [Tags::Role->value] diff --git a/src/Role/Controller/UpdateRoleController.php b/src/Role/Controller/UpdateRoleController.php index b634c02e..da7e0303 100644 --- a/src/Role/Controller/UpdateRoleController.php +++ b/src/Role/Controller/UpdateRoleController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/role/{id}', name: 'pimcore_studio_api_role_update', methods: ['PUT'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Put( - path: self::API_PATH . '/role/{id}', + path: self::PREFIX . '/role/{id}', operationId: 'role_update_by_id', summary: 'role_update_by_id_summary', tags: [Tags::Role->value] diff --git a/src/Schedule/Controller/DeleteController.php b/src/Schedule/Controller/DeleteController.php index be0dfb0d..66cb753e 100644 --- a/src/Schedule/Controller/DeleteController.php +++ b/src/Schedule/Controller/DeleteController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/schedules/{id}', name: 'pimcore_studio_api_delete_schedule', methods: ['DELETE'])] #[IsGranted(UserPermissions::PIMCORE_USER->value)] #[Delete( - path: self::API_PATH . '/schedules/{id}', + path: self::PREFIX . '/schedules/{id}', operationId: 'schedule_delete_by_id', description: 'schedule_delete_by_id_description', summary: 'schedule_delete_by_id_summary', diff --git a/src/Schedule/Controller/Element/CollectionController.php b/src/Schedule/Controller/Element/CollectionController.php index 7b6b64d6..245ccbd8 100644 --- a/src/Schedule/Controller/Element/CollectionController.php +++ b/src/Schedule/Controller/Element/CollectionController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/schedules/{elementType}/{id}', name: 'pimcore_studio_api_get_element_schedules', methods: ['GET'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/schedules/{elementType}/{id}', + path: self::PREFIX . '/schedules/{elementType}/{id}', operationId: 'schedule_get_collection_for_element_by_type_and_id', description: 'schedule_get_collection_for_element_by_type_and_id_description', summary: 'schedule_get_collection_for_element_by_type_and_id_summary', diff --git a/src/Schedule/Controller/Element/CreateController.php b/src/Schedule/Controller/Element/CreateController.php index e479cd98..68396686 100644 --- a/src/Schedule/Controller/Element/CreateController.php +++ b/src/Schedule/Controller/Element/CreateController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/schedules/{elementType}/{id}', name: 'pimcore_studio_api_create_schedule', methods: ['POST'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[POST( - path: self::API_PATH . '/schedules/{elementType}/{id}', + path: self::PREFIX . '/schedules/{elementType}/{id}', operationId: 'schedule_create_for_element_by_type_and_id', description: 'schedule_create_for_element_by_type_and_id_description', summary: 'schedule_create_for_element_by_type_and_id_summary', diff --git a/src/Schedule/Controller/Element/UpdateController.php b/src/Schedule/Controller/Element/UpdateController.php index b96f14bb..0747ae21 100644 --- a/src/Schedule/Controller/Element/UpdateController.php +++ b/src/Schedule/Controller/Element/UpdateController.php @@ -59,7 +59,7 @@ public function __construct( #[Route('/schedules/{elementType}/{id}', name: 'pimcore_studio_api_update_schedules', methods: ['PUT'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Put( - path: self::API_PATH . '/schedules/{elementType}/{id}', + path: self::PREFIX . '/schedules/{elementType}/{id}', operationId: 'schedule_update_for_element_by_type_and_id', description: 'schedule_update_for_element_by_type_and_id_description', summary: 'schedule_update_for_element_by_type_and_id_summary', diff --git a/src/Setting/Controller/GetController.php b/src/Setting/Controller/GetController.php index b48839ac..18bb9ce8 100644 --- a/src/Setting/Controller/GetController.php +++ b/src/Setting/Controller/GetController.php @@ -43,7 +43,7 @@ public function __construct( #[Route(path: self::ROUTE, name: 'pimcore_studio_api_settings', methods: ['GET'])] #[Get( - path: self::API_PATH . self::ROUTE, + path: self::PREFIX . self::ROUTE, operationId: 'system_settings_get', description: 'system_settings_get_description', summary: 'system_settings_get_summary', diff --git a/src/Tag/Controller/CollectionController.php b/src/Tag/Controller/CollectionController.php index 6f3c2c85..a9832d36 100644 --- a/src/Tag/Controller/CollectionController.php +++ b/src/Tag/Controller/CollectionController.php @@ -60,7 +60,7 @@ public function __construct( #[Route('/tags', name: 'pimcore_studio_api_tags', methods: ['GET'])] #[IsGranted(UserPermissions::TAGS_SEARCH->value)] #[Get( - path: self::API_PATH . '/tags', + path: self::PREFIX . '/tags', operationId: 'tag_get_collection', description: 'tag_get_collection_description', summary: 'tag_get_collection_summary', diff --git a/src/Tag/Controller/CreateController.php b/src/Tag/Controller/CreateController.php index 6e3752af..2d36031c 100644 --- a/src/Tag/Controller/CreateController.php +++ b/src/Tag/Controller/CreateController.php @@ -52,7 +52,7 @@ public function __construct( */ #[Route('/tag', name: 'pimcore_studio_api_create_tag', methods: ['POST'])] #[POST( - path: self::API_PATH . '/tag', + path: self::PREFIX . '/tag', operationId: 'tag_create', description: 'tag_create_description', summary: 'tag_create_summary', diff --git a/src/Tag/Controller/DeleteController.php b/src/Tag/Controller/DeleteController.php index 53e6e220..da5ba6b5 100644 --- a/src/Tag/Controller/DeleteController.php +++ b/src/Tag/Controller/DeleteController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/tags/{id}', name: 'pimcore_studio_api_delete_tags', methods: ['DELETE'])] #[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)] #[Delete( - path: self::API_PATH . '/tags/{id}', + path: self::PREFIX . '/tags/{id}', operationId: 'tag_delete_by_id', description: 'tag_delete_by_id_description', summary: 'tag_delete_by_id_summary', diff --git a/src/Tag/Controller/Element/AssignController.php b/src/Tag/Controller/Element/AssignController.php index 72a89e15..53b3d9d2 100644 --- a/src/Tag/Controller/Element/AssignController.php +++ b/src/Tag/Controller/Element/AssignController.php @@ -55,7 +55,7 @@ public function __construct( ] #[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)] #[Post( - path: self::API_PATH . '/tags/assign/{elementType}/{id}/{tagId}', + path: self::PREFIX . '/tags/assign/{elementType}/{id}/{tagId}', operationId: 'tag_assign_to_element', description: 'tag_assign_to_element_description', summary: 'tag_assign_to_element_summary', diff --git a/src/Tag/Controller/Element/BatchAssignController.php b/src/Tag/Controller/Element/BatchAssignController.php index 43908351..fe09f276 100644 --- a/src/Tag/Controller/Element/BatchAssignController.php +++ b/src/Tag/Controller/Element/BatchAssignController.php @@ -58,7 +58,7 @@ public function __construct( )] #[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)] #[Post( - path: self::API_PATH . '/tags/batch/assign/{elementType}', + path: self::PREFIX . '/tags/batch/assign/{elementType}', operationId: 'tag_batch_assign_to_elements_by_type', description: 'tag_batch_assign_to_elements_by_type_description', summary: 'tag_batch_assign_to_elements_by_type_summary', diff --git a/src/Tag/Controller/Element/BatchReplaceController.php b/src/Tag/Controller/Element/BatchReplaceController.php index 16074de5..4857507f 100644 --- a/src/Tag/Controller/Element/BatchReplaceController.php +++ b/src/Tag/Controller/Element/BatchReplaceController.php @@ -58,7 +58,7 @@ public function __construct( )] #[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)] #[Post( - path: self::API_PATH . '/tags/batch/replace/{elementType}', + path: self::PREFIX . '/tags/batch/replace/{elementType}', operationId: 'tag_batch_replace_for_elements_by_type', description: 'tag_batch_replace_for_elements_by_type_description', summary: 'tag_batch_replace_for_elements_by_type_summary', diff --git a/src/Tag/Controller/Element/CollectionController.php b/src/Tag/Controller/Element/CollectionController.php index ec7d834e..a2bd6d66 100644 --- a/src/Tag/Controller/Element/CollectionController.php +++ b/src/Tag/Controller/Element/CollectionController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/tags/{elementType}/{id}', name: 'pimcore_studio_api_get_element_tags', methods: ['GET'])] #[IsGranted(UserPermissions::TAGS_SEARCH->value)] #[Get( - path: self::API_PATH . '/tags/{elementType}/{id}', + path: self::PREFIX . '/tags/{elementType}/{id}', operationId: 'tag_get_collection_for_element_by_type_and_id', description: 'tag_get_collection_for_element_by_type_and_id_description', summary: 'tag_get_collection_for_element_by_type_and_id_summary', diff --git a/src/Tag/Controller/Element/UnassignController.php b/src/Tag/Controller/Element/UnassignController.php index 99d9d256..71a235fd 100644 --- a/src/Tag/Controller/Element/UnassignController.php +++ b/src/Tag/Controller/Element/UnassignController.php @@ -51,7 +51,7 @@ public function __construct( #[Route('/tags/{elementType}/{id}/{tagId}', name: 'pimcore_studio_api_unassign_element_tag', methods: ['DELETE'])] #[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)] #[Delete( - path: self::API_PATH . '/tags/{elementType}/{id}/{tagId}', + path: self::PREFIX . '/tags/{elementType}/{id}/{tagId}', operationId: 'tag_unassign_from_element', description: 'tag_unassign_from_element_description', summary: 'tag_unassign_from_element_summary', diff --git a/src/Tag/Controller/GetController.php b/src/Tag/Controller/GetController.php index 0835f3ba..f83482b1 100644 --- a/src/Tag/Controller/GetController.php +++ b/src/Tag/Controller/GetController.php @@ -47,7 +47,7 @@ public function __construct( #[Route('/tags/{id}', name: 'pimcore_studio_api_get_tag', methods: ['GET'])] #[IsGranted(UserPermissions::TAGS_SEARCH->value)] #[Get( - path: self::API_PATH . '/tags/{id}', + path: self::PREFIX . '/tags/{id}', operationId: 'tag_get_by_id', description: 'tag_get_by_id_description', summary: 'tag_get_by_id_summary', diff --git a/src/Tag/Controller/UpdateController.php b/src/Tag/Controller/UpdateController.php index a81d8c8e..91ce2509 100644 --- a/src/Tag/Controller/UpdateController.php +++ b/src/Tag/Controller/UpdateController.php @@ -49,7 +49,7 @@ public function __construct( #[Route('/tags/{id}', name: 'pimcore_studio_api_update_tag', methods: ['PUT'])] #[Put( - path: self::API_PATH . '/tags/{id}', + path: self::PREFIX . '/tags/{id}', operationId: 'tag_update_by_id', description: 'tag_update_by_id_description', summary: 'tag_update_by_id_summary', diff --git a/src/Thumbnail/Controller/ImageCollectionController.php b/src/Thumbnail/Controller/ImageCollectionController.php index 42a70fb8..9299a1e3 100644 --- a/src/Thumbnail/Controller/ImageCollectionController.php +++ b/src/Thumbnail/Controller/ImageCollectionController.php @@ -53,7 +53,7 @@ public function __construct( #[IsGranted(UserPermissions::ASSETS->value)] #[IsGranted(UserPermissions::THUMBNAILS->value)] #[Get( - path: self::API_PATH . '/thumbnails/image', + path: self::PREFIX . '/thumbnails/image', operationId: 'thumbnail_image_get_collection', description: 'thumbnail_image_get_collection_description', summary: 'thumbnail_image_get_collection_summary', diff --git a/src/Thumbnail/Controller/VideoCollectionController.php b/src/Thumbnail/Controller/VideoCollectionController.php index 9d49e7c2..f18e3005 100644 --- a/src/Thumbnail/Controller/VideoCollectionController.php +++ b/src/Thumbnail/Controller/VideoCollectionController.php @@ -53,7 +53,7 @@ public function __construct( #[IsGranted(UserPermissions::ASSETS->value)] #[IsGranted(UserPermissions::THUMBNAILS->value)] #[Get( - path: self::API_PATH . '/thumbnails/video', + path: self::PREFIX . '/thumbnails/video', operationId: 'thumbnail_video_get_collection', description: 'thumbnail_video_get_collection_description', summary: 'thumbnail_video_get_collection_summary', diff --git a/src/Translation/Controller/TranslationController.php b/src/Translation/Controller/TranslationController.php index 1ea146dc..4c1ba5ff 100644 --- a/src/Translation/Controller/TranslationController.php +++ b/src/Translation/Controller/TranslationController.php @@ -53,7 +53,7 @@ public function __construct( #[Route(self::ROUTE, name: 'pimcore_studio_api_translations', methods: ['POST'])] #[IsGranted(self::VOTER_PUBLIC_STUDIO_API, 'translation')] #[POST( - path: self::API_PATH . self::ROUTE, + path: self::PREFIX . self::ROUTE, operationId: 'translation_get_collection', description: 'translation_get_collection_description', summary: 'translation_get_collection_summary', diff --git a/src/User/Controller/CloneController.php b/src/User/Controller/CloneController.php index 9650e172..ec492424 100644 --- a/src/User/Controller/CloneController.php +++ b/src/User/Controller/CloneController.php @@ -58,7 +58,7 @@ public function __construct( #[Route('/user/clone/{id}', name: 'pimcore_studio_api_user_clone', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/user/clone/{id}', + path: self::PREFIX . '/user/clone/{id}', operationId: 'user_clone_by_id', summary: 'user_clone_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/CreateUserController.php b/src/User/Controller/CreateUserController.php index e0ec30b2..e9a3a372 100644 --- a/src/User/Controller/CreateUserController.php +++ b/src/User/Controller/CreateUserController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/user/', name: 'pimcore_studio_api_user_create', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/user/', + path: self::PREFIX . '/user/', operationId: 'user_create', summary: 'user_create_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/CreateUserFolderController.php b/src/User/Controller/CreateUserFolderController.php index 86c9aeb9..60422991 100644 --- a/src/User/Controller/CreateUserFolderController.php +++ b/src/User/Controller/CreateUserFolderController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/user/folder', name: 'pimcore_studio_api_user_folder_create', methods: ['POST'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Post( - path: self::API_PATH . '/user/folder', + path: self::PREFIX . '/user/folder', operationId: 'user_folder_create', summary: 'user_folder_create_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/CurrentUserController.php b/src/User/Controller/CurrentUserController.php index 131706bc..36037425 100644 --- a/src/User/Controller/CurrentUserController.php +++ b/src/User/Controller/CurrentUserController.php @@ -36,7 +36,7 @@ final class CurrentUserController extends AbstractApiController { #[Route('/user/current-user-information', name: 'pimcore_studio_api_current_user', methods: ['GET'])] #[Get( - path: self::API_PATH . '/user/current-user-information', + path: self::PREFIX . '/user/current-user-information', operationId: 'user_get_current_information', summary: 'user_get_current_information_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/DeleteUserController.php b/src/User/Controller/DeleteUserController.php index 75393af2..b0d8c9d5 100644 --- a/src/User/Controller/DeleteUserController.php +++ b/src/User/Controller/DeleteUserController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/user/{id}', name: 'pimcore_studio_api_user_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Delete( - path: self::API_PATH . '/user/{id}', + path: self::PREFIX . '/user/{id}', operationId: 'user_delete_by_id', summary: 'user_delete_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/DeleteUserFolderController.php b/src/User/Controller/DeleteUserFolderController.php index 12673495..02475bde 100644 --- a/src/User/Controller/DeleteUserFolderController.php +++ b/src/User/Controller/DeleteUserFolderController.php @@ -54,7 +54,7 @@ public function __construct( #[Route('/user/folder/{id}', name: 'pimcore_studio_api_user_folder_delete', methods: ['DELETE'])] #[IsGranted(UserPermissions::PIMCORE_ADMIN->value)] #[Delete( - path: self::API_PATH . '/user/folder/{id}', + path: self::PREFIX . '/user/folder/{id}', operationId: 'user_folder_delete_by_id', summary: 'user_folder_delete_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/GetUserController.php b/src/User/Controller/GetUserController.php index 917a9d35..32a1c199 100644 --- a/src/User/Controller/GetUserController.php +++ b/src/User/Controller/GetUserController.php @@ -55,7 +55,7 @@ public function __construct( #[Route('/user/{id}', name: 'pimcore_studio_api_user_get', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/user/{id}', + path: self::PREFIX . '/user/{id}', operationId: 'user_get_by_id', summary: 'user_get_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/GetUserPermissionsController.php b/src/User/Controller/GetUserPermissionsController.php index 2bf194a3..df5abc24 100644 --- a/src/User/Controller/GetUserPermissionsController.php +++ b/src/User/Controller/GetUserPermissionsController.php @@ -49,7 +49,7 @@ public function __construct( #[Route('/user/available-permissions', name: 'pimcore_studio_api_user_available_permissions', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/user/available-permissions', + path: self::PREFIX . '/user/available-permissions', operationId: 'user_get_available_permissions', summary: 'user_get_available_permissions_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/GetUsersController.php b/src/User/Controller/GetUsersController.php index e6f0b4bb..532ebe0d 100644 --- a/src/User/Controller/GetUsersController.php +++ b/src/User/Controller/GetUsersController.php @@ -49,7 +49,7 @@ public function __construct( #[Route('/users', name: 'pimcore_studio_api_users', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/users', + path: self::PREFIX . '/users', operationId: 'user_get_collection', description: 'user_get_collection_description', summary: 'user_get_collection_summary', diff --git a/src/User/Controller/ResetPasswordController.php b/src/User/Controller/ResetPasswordController.php index 7f16426b..6b728cc3 100644 --- a/src/User/Controller/ResetPasswordController.php +++ b/src/User/Controller/ResetPasswordController.php @@ -50,7 +50,7 @@ public function __construct( */ #[Route('/user/reset-password', name: 'pimcore_studio_api_user_reset_password', methods: ['POST'])] #[Post( - path: self::API_PATH . '/user/reset-password', + path: self::PREFIX . '/user/reset-password', operationId: 'user_reset_password', summary: 'user_reset_password_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/UpdatePasswordController.php b/src/User/Controller/UpdatePasswordController.php index c7892eba..d6435063 100644 --- a/src/User/Controller/UpdatePasswordController.php +++ b/src/User/Controller/UpdatePasswordController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/user/{id}/password', name: 'pimcore_studio_api_user_password_update', methods: ['PUT'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Put( - path: self::API_PATH . '/user/{id}/password', + path: self::PREFIX . '/user/{id}/password', operationId: 'user_update_password_by_id', summary: 'user_update_password_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/UpdateUserController.php b/src/User/Controller/UpdateUserController.php index 3a95cb48..a3291460 100644 --- a/src/User/Controller/UpdateUserController.php +++ b/src/User/Controller/UpdateUserController.php @@ -63,7 +63,7 @@ public function __construct( #[Route('/user/{id}', name: 'pimcore_studio_api_user_update', methods: ['PUT'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Put( - path: self::API_PATH . '/user/{id}', + path: self::PREFIX . '/user/{id}', operationId: 'user_update_by_id', summary: 'user_update_by_id_summary', tags: [Tags::User->value] diff --git a/src/User/Controller/UserTreeController.php b/src/User/Controller/UserTreeController.php index 5501ceaf..76425683 100644 --- a/src/User/Controller/UserTreeController.php +++ b/src/User/Controller/UserTreeController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/users/tree', name: 'pimcore_studio_api_user_tree', methods: ['GET'])] #[IsGranted(UserPermissions::USER_MANAGEMENT->value)] #[Get( - path: self::API_PATH . '/users/tree', + path: self::PREFIX . '/users/tree', operationId: 'user_get_tree', summary: 'user_get_tree_summary', tags: [Tags::User->value] diff --git a/src/Util/Trait/StudioBackendPathTrait.php b/src/Util/Trait/StudioBackendPathTrait.php index e4c3c2d0..b5d12505 100644 --- a/src/Util/Trait/StudioBackendPathTrait.php +++ b/src/Util/Trait/StudioBackendPathTrait.php @@ -25,6 +25,6 @@ trait StudioBackendPathTrait { private function isStudioBackendPath(string $path): bool { - return str_starts_with($path, AbstractApiController::API_PATH); + return str_starts_with($path, AbstractApiController::PREFIX); } } diff --git a/src/Version/Controller/Asset/DownloadController.php b/src/Version/Controller/Asset/DownloadController.php index c56be8d5..0229043b 100644 --- a/src/Version/Controller/Asset/DownloadController.php +++ b/src/Version/Controller/Asset/DownloadController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/versions/{id}/asset/download', name: 'pimcore_studio_api_download_asset_version', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/versions/{id}/asset/download', + path: self::PREFIX . '/versions/{id}/asset/download', operationId: 'version_asset_download_by_id', description: 'version_asset_download_by_id_description', summary: 'version_asset_download_by_id_summary', diff --git a/src/Version/Controller/Asset/ImageStreamController.php b/src/Version/Controller/Asset/ImageStreamController.php index 37a137d9..738b07de 100644 --- a/src/Version/Controller/Asset/ImageStreamController.php +++ b/src/Version/Controller/Asset/ImageStreamController.php @@ -57,7 +57,7 @@ public function __construct( #[Route('/versions/{id}/image/stream', name: 'pimcore_studio_api_stream_image_version', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/versions/{id}/image/stream', + path: self::PREFIX . '/versions/{id}/image/stream', operationId: 'version_image_stream_by_id', description: 'version_image_stream_by_id_description', summary: 'version_image_stream_by_id_summary', diff --git a/src/Version/Controller/Asset/PdfStreamController.php b/src/Version/Controller/Asset/PdfStreamController.php index 5db55712..285f7330 100644 --- a/src/Version/Controller/Asset/PdfStreamController.php +++ b/src/Version/Controller/Asset/PdfStreamController.php @@ -66,7 +66,7 @@ public function __construct( #[Route('/versions/{id}/pdf/stream', name: 'pimcore_studio_api_stream_pdf_version', methods: ['GET'])] #[IsGranted(UserPermissions::ASSETS->value)] #[Get( - path: self::API_PATH . '/versions/{id}/pdf/stream', + path: self::PREFIX . '/versions/{id}/pdf/stream', operationId: 'version_pdf_stream_by_id', description: 'version_pdf_stream_by_id_description', summary: 'version_pdf_stream_by_id_summary', diff --git a/src/Version/Controller/DeleteController.php b/src/Version/Controller/DeleteController.php index 5f829aa7..41cee7ce 100644 --- a/src/Version/Controller/DeleteController.php +++ b/src/Version/Controller/DeleteController.php @@ -52,7 +52,7 @@ public function __construct( #[Route('/versions/{id}', name: 'pimcore_studio_api_delete_version', methods: ['DELETE'])] //#[IsGranted('STUDIO_API')] #[Delete( - path: self::API_PATH . '/versions/{id}', + path: self::PREFIX . '/versions/{id}', operationId: 'version_delete_by_id', description: 'version_delete_by_id_description', summary: 'version_delete_by_id_summary', diff --git a/src/Version/Controller/Element/CleanupController.php b/src/Version/Controller/Element/CleanupController.php index 824c9fad..4a9cef09 100644 --- a/src/Version/Controller/Element/CleanupController.php +++ b/src/Version/Controller/Element/CleanupController.php @@ -56,7 +56,7 @@ public function __construct( #[Route('/versions/{elementType}/{id}', name: 'pimcore_studio_api_cleanup_versions', methods: ['DELETE'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Delete( - path: self::API_PATH . '/versions/{elementType}/{id}', + path: self::PREFIX . '/versions/{elementType}/{id}', operationId: 'version_cleanup_for_element_by_type_and_id', description: 'version_cleanup_for_element_by_type_and_id_description', summary: 'version_cleanup_for_element_by_type_and_id_summary', diff --git a/src/Version/Controller/Element/CollectionController.php b/src/Version/Controller/Element/CollectionController.php index 90700392..e7b610b5 100644 --- a/src/Version/Controller/Element/CollectionController.php +++ b/src/Version/Controller/Element/CollectionController.php @@ -64,7 +64,7 @@ public function __construct( #[Route('/versions/{elementType}/{id}', name: 'pimcore_studio_api_versions', methods: ['GET'])] #[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)] #[Get( - path: self::API_PATH . '/versions/{elementType}/{id}', + path: self::PREFIX . '/versions/{elementType}/{id}', operationId: 'version_get_collection_for_element_by_type_and_id', description: 'version_get_collection_for_element_by_type_and_id_description', summary: 'version_get_collection_for_element_by_type_and_id_summary', diff --git a/src/Version/Controller/GetController.php b/src/Version/Controller/GetController.php index e5719e8d..d27a474d 100644 --- a/src/Version/Controller/GetController.php +++ b/src/Version/Controller/GetController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/versions/{id}', name: 'pimcore_studio_api_get_version', methods: ['GET'])] //#[IsGranted('STUDIO_API')] #[Get( - path: self::API_PATH . '/versions/{id}', + path: self::PREFIX . '/versions/{id}', operationId: 'version_get_by_id', description: 'version_get_by_id_description', summary: 'version_get_by_id_summary', diff --git a/src/Version/Controller/PublishController.php b/src/Version/Controller/PublishController.php index 9963ed0a..ce4add04 100644 --- a/src/Version/Controller/PublishController.php +++ b/src/Version/Controller/PublishController.php @@ -58,7 +58,7 @@ public function __construct( #[Route('/versions/{id}', name: 'pimcore_studio_api_publish_version', methods: ['POST'])] //#[IsGranted('STUDIO_API')] #[Post( - path: self::API_PATH . '/versions/{id}', + path: self::PREFIX . '/versions/{id}', operationId: 'version_publish_by_id', description: 'version_publish_by_id_description', summary: 'version_publish_by_id_summary', diff --git a/src/Version/Controller/UpdateController.php b/src/Version/Controller/UpdateController.php index 28927b41..901488b4 100644 --- a/src/Version/Controller/UpdateController.php +++ b/src/Version/Controller/UpdateController.php @@ -55,7 +55,7 @@ public function __construct( */ #[Route('/versions/{id}', name: 'pimcore_studio_api_update_version', methods: ['PUT'])] #[Put( - path: self::API_PATH . '/versions/{id}', + path: self::PREFIX . '/versions/{id}', operationId: 'version_update_by_id', description: 'version_update_by_id_description', summary: 'version_update_by_id_summary', diff --git a/src/Workflow/Controller/DetailsCollectionController.php b/src/Workflow/Controller/DetailsCollectionController.php index 0f9dd10a..1d84835c 100644 --- a/src/Workflow/Controller/DetailsCollectionController.php +++ b/src/Workflow/Controller/DetailsCollectionController.php @@ -53,7 +53,7 @@ public function __construct( #[Route('/workflows/details', name: 'pimcore_studio_api_element_workflows_details', methods: ['GET'])] //#[IsGranted('STUDIO_API')] #[Get( - path: self::API_PATH . '/workflows/details', + path: self::PREFIX . '/workflows/details', operationId: 'workflow_get_details', description: 'workflow_get_details_description', summary: 'workflow_get_details_summary', diff --git a/src/Workflow/Controller/SubmitActionController.php b/src/Workflow/Controller/SubmitActionController.php index 4660d1a0..e1a9cbbd 100644 --- a/src/Workflow/Controller/SubmitActionController.php +++ b/src/Workflow/Controller/SubmitActionController.php @@ -52,7 +52,7 @@ public function __construct( )] //#[IsGranted('STUDIO_API')] #[Post( - path: self::API_PATH . '/workflows/action', + path: self::PREFIX . '/workflows/action', operationId: 'workflow_action_submit', description: 'workflow_action_submit_description', summary: 'workflow_action_submit_summary', From 65c0f1070ac268580a583330ef8df2e4884a4e56 Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Mon, 14 Oct 2024 15:36:36 +0200 Subject: [PATCH 7/7] [Grid] [DataObject] List available columns for object Bricks (#488) * Initial Object Brick Collector. * Apply php-cs-fixer changes * Small fixes. * Apply php-cs-fixer changes --------- Co-authored-by: martineiber --- config/grid.yaml | 10 + .../DataObject/FieldDefinitionCollector.php | 58 +----- .../DataObject/ObjectBrickCollector.php | 172 ++++++++++++++++++ .../DataObject/SystemFieldCollector.php | 2 +- src/Grid/Service/ClassDefinitionService.php | 96 ++++++++++ .../ClassDefinitionServiceInterface.php | 42 +++++ .../Service/ColumnConfigurationService.php | 23 +++ .../ColumnConfigurationServiceInterface.php | 3 + 8 files changed, 355 insertions(+), 51 deletions(-) create mode 100644 src/Grid/Column/Collector/DataObject/ObjectBrickCollector.php create mode 100644 src/Grid/Service/ClassDefinitionService.php create mode 100644 src/Grid/Service/ClassDefinitionServiceInterface.php diff --git a/config/grid.yaml b/config/grid.yaml index c88ec66b..3bfe3a57 100644 --- a/config/grid.yaml +++ b/config/grid.yaml @@ -12,6 +12,9 @@ services: Pimcore\Bundle\StudioBackendBundle\Grid\Mapper\ColumnMapperInterface: class: Pimcore\Bundle\StudioBackendBundle\Grid\Mapper\ColumnMapper + # + # Services + # Pimcore\Bundle\StudioBackendBundle\Grid\Service\GridServiceInterface: class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\GridService @@ -21,6 +24,9 @@ services: Pimcore\Bundle\StudioBackendBundle\Grid\Service\ColumnConfigurationServiceInterface: class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\ColumnConfigurationService + Pimcore\Bundle\StudioBackendBundle\Grid\Service\ClassDefinitionServiceInterface: + class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\ClassDefinitionService + Pimcore\Bundle\StudioBackendBundle\Grid\Service\SystemColumnServiceInterface: class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\SystemColumnService @@ -38,6 +44,7 @@ services: Pimcore\Bundle\StudioBackendBundle\Grid\Service\UserRoleShareServiceInterface: class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\UserRoleShareService + # # Repository # @@ -160,5 +167,8 @@ services: Pimcore\Bundle\StudioBackendBundle\Grid\Column\Collector\DataObject\FieldDefinitionCollector: tags: [ 'pimcore.studio_backend.grid_column_collector' ] + Pimcore\Bundle\StudioBackendBundle\Grid\Column\Collector\DataObject\ObjectBrickCollector: + tags: [ 'pimcore.studio_backend.grid_column_collector' ] + Pimcore\Bundle\StudioBackendBundle\Grid\Column\Collector\Asset\MetadataCollector: tags: [ 'pimcore.studio_backend.grid_column_collector' ] \ No newline at end of file diff --git a/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php b/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php index 6a553204..2f695117 100644 --- a/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php +++ b/src/Grid/Column/Collector/DataObject/FieldDefinitionCollector.php @@ -16,16 +16,14 @@ namespace Pimcore\Bundle\StudioBackendBundle\Grid\Column\Collector\DataObject; -use Exception; -use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassDefinitionResolverInterface; -use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\DataObjectServiceResolverInterface; -use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ClassIdInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\ColumnCollectorInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\FolderIdInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\UseClassIdTrait; use Pimcore\Bundle\StudioBackendBundle\Grid\Column\UseFolderIdTrait; use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\ColumnConfiguration; +use Pimcore\Bundle\StudioBackendBundle\Grid\Service\ClassDefinitionServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Grid\Service\ColumnConfigurationServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Grid\Util\ColumnFieldDefinition; use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes; use Pimcore\Model\DataObject\ClassDefinition\Data; @@ -47,8 +45,8 @@ final class FieldDefinitionCollector implements ColumnCollectorInterface, ClassI private array $groupedDefinitions = []; public function __construct( - private readonly ClassDefinitionResolverInterface $classDefinitionResolver, - private readonly DataObjectServiceResolverInterface $dataObjectServiceResolver, + private readonly ClassDefinitionServiceInterface $classDefinitionService, + private readonly ColumnConfigurationServiceInterface $columnConfigurationService ) { } @@ -59,31 +57,12 @@ public function getCollectorName(): string public function getColumnConfigurations(array $availableColumnDefinitions): array { - try { - $classDefinition = $this->classDefinitionResolver->getById($this->getClassId()); - } catch (Exception) { - $classDefinition = null; - } - - if (!$classDefinition) { - throw new NotFoundException('Class definition', $this->getClassId()); - } - - $filteredDefinitions = $this->dataObjectServiceResolver->getCustomLayoutDefinitionForGridColumnConfig( - $classDefinition, + $layoutDefinitions = $this->classDefinitionService->getFilteredLayoutDefinitions( + $this->getClassId(), $this->getFolderId() ); - if (!isset($filteredDefinitions['layoutDefinition'])) { - return []; - } - - /** @var Layout $layoutDefinitions */ - $layoutDefinitions = $filteredDefinitions['layoutDefinition']; - - $this->dataObjectServiceResolver->enrichLayoutDefinition( - $layoutDefinitions - ); + $classDefinition = $this->classDefinitionService->getClassDefinition($this->getClassId()); $children = $layoutDefinitions->getChildren(); @@ -143,33 +122,12 @@ private function buildColumnConfigurations(): array { $columns = []; foreach ($this->groupedDefinitions as $definition) { - $columns[] = $this->buildColumnConfiguration($definition); + $columns[] = $this->columnConfigurationService->buildColumnConfiguration($definition); } return $columns; } - private function buildColumnConfiguration(ColumnFieldDefinition $definition): ColumnConfiguration - { - $options = null; - $fieldDefinition = $definition->getFieldDefinition(); - if ($fieldDefinition instanceof Data\Select) { - $options = $fieldDefinition->getOptions(); - } - - return new ColumnConfiguration( - key: $fieldDefinition->getName(), - group: $definition->getGroup(), - sortable: true, - editable: !$fieldDefinition->getNoteditable(), - localizable: $definition->isLocalized(), - locale: null, - type: 'dataobject.' . $fieldDefinition->getFieldType(), - frontendType: $fieldDefinition->getFieldType(), - config: $options ? ['options' => $options] : [], - ); - } - public function supportedElementTypes(): array { return [ diff --git a/src/Grid/Column/Collector/DataObject/ObjectBrickCollector.php b/src/Grid/Column/Collector/DataObject/ObjectBrickCollector.php new file mode 100644 index 00000000..b9113370 --- /dev/null +++ b/src/Grid/Column/Collector/DataObject/ObjectBrickCollector.php @@ -0,0 +1,172 @@ +load(); + + $classDefinition = $this->classDefinitionService->getClassDefinition($this->getClassId()); + + $filteredFieldDefinitions = $this->classDefinitionService->getFilteredFieldDefinitions( + $this->getClassId(), + $this->getFolderId() + ); + + foreach ($objectBrickList as $objectBrick) { + + if (empty($objectBrick->getClassDefinitions())) { + continue; + } + + if (!$this->usesClass($objectBrick, $classDefinition)) { + continue; + } + + $fieldName = $this->getUsedFieldName($objectBrick, $classDefinition); + + if (!$this->fieldNameExists($fieldName, $filteredFieldDefinitions)) { + continue; + } + + $this->buildColumnConfigurations($objectBrick); + + } + + return $this->configurations; + } + + private function buildColumnConfigurations(ObjectBrickDefinition $objectBrick): void + { + $dataFields = $this->getDataFields($objectBrick->getLayoutDefinitions()); + + foreach ($dataFields as $dataField) { + $groupName = $objectBrick->getTitle() !== '' ? $objectBrick->getTitle() : $objectBrick->getKey(); + + $this->configurations[] = $this->columnConfigurationService->buildColumnConfiguration( + new ColumnFieldDefinition($dataField, $groupName, false) + ); + } + } + + public function getDataFields(Layout $layout): array + { + $dataFields = []; + foreach ($layout->getChildren() as $child) { + if ($child instanceof Layout) { + $dataFields = [...$dataFields, ...$this->getDataFields($child)]; + } + + if ($child instanceof ClassDefinition\Data) { + $dataFields = [...$dataFields, $child]; + } + } + + return $dataFields; + } + + private function usesClass(ObjectBrickDefinition $objectBrick, ClassDefinition $classDefinition): bool + { + foreach ($objectBrick->getClassDefinitions() as $usedClassDefinition) { + if ($usedClassDefinition['classname'] === $classDefinition->getName()) { + return true; + } + } + + return false; + } + + private function getUsedFieldName(ObjectBrickDefinition $objectBrick, ClassDefinition $classDefinition): string + { + foreach ($objectBrick->getClassDefinitions() as $usedClassDefinition) { + if ($usedClassDefinition['classname'] === $classDefinition->getName()) { + return $usedClassDefinition['fieldname']; + } + } + + throw new InvalidArgumentException('Field not found'); + } + + private function fieldNameExists(string $fieldName, array $filteredFieldDefinitions): bool + { + if (empty($filteredFieldDefinitions)) { + return true; + } + + if ( + array_key_exists($fieldName, $filteredFieldDefinitions) && + $filteredFieldDefinitions[$fieldName] instanceof Objectbricks + ) { + return true; + } + + return false; + } + + public function supportedElementTypes(): array + { + return [ + ElementTypes::TYPE_DATA_OBJECT, + ]; + } +} diff --git a/src/Grid/Column/Collector/DataObject/SystemFieldCollector.php b/src/Grid/Column/Collector/DataObject/SystemFieldCollector.php index 1fd83bb6..c21abe06 100644 --- a/src/Grid/Column/Collector/DataObject/SystemFieldCollector.php +++ b/src/Grid/Column/Collector/DataObject/SystemFieldCollector.php @@ -26,7 +26,7 @@ /** * @internal */ -final class SystemFieldCollector implements ColumnCollectorInterface +final readonly class SystemFieldCollector implements ColumnCollectorInterface { public function __construct( private SystemColumnServiceInterface $systemColumnService, diff --git a/src/Grid/Service/ClassDefinitionService.php b/src/Grid/Service/ClassDefinitionService.php new file mode 100644 index 00000000..4b6af583 --- /dev/null +++ b/src/Grid/Service/ClassDefinitionService.php @@ -0,0 +1,96 @@ +getClassDefinition($classId); + + $filteredDefinitions = $this->dataObjectServiceResolver->getCustomLayoutDefinitionForGridColumnConfig( + $classDefinition, + $folderId + ); + + if (!isset($filteredDefinitions['layoutDefinition'])) { + return null; + } + + /** @var Layout $layoutDefinitions */ + $layoutDefinitions = $filteredDefinitions['layoutDefinition']; + + $this->dataObjectServiceResolver->enrichLayoutDefinition( + $layoutDefinitions + ); + + return $layoutDefinitions; + } + + public function getFilteredFieldDefinitions(string $classId, int $folderId): array + { + $classDefinition = $this->getClassDefinition($classId); + + $filteredDefinitions = $this->dataObjectServiceResolver->getCustomLayoutDefinitionForGridColumnConfig( + $classDefinition, + $folderId + ); + + if (!isset($filteredDefinitions['fieldDefinition'])) { + return []; + } + + return $filteredDefinitions['fieldDefinition']; + } + + /** + * @inheritDoc + */ + public function getClassDefinition(string $classId): ClassDefinition + { + try { + $classDefinition = $this->classDefinitionResolver->getById($classId); + } catch (Exception) { + $classDefinition = null; + } + + if (!$classDefinition) { + throw new NotFoundException('Class definition', $classId); + } + + return $classDefinition; + } +} diff --git a/src/Grid/Service/ClassDefinitionServiceInterface.php b/src/Grid/Service/ClassDefinitionServiceInterface.php new file mode 100644 index 00000000..ef12ab9a --- /dev/null +++ b/src/Grid/Service/ClassDefinitionServiceInterface.php @@ -0,0 +1,42 @@ +getFieldDefinition(); + if ($fieldDefinition instanceof Select) { + $options = $fieldDefinition->getOptions(); + } + + return new ColumnConfiguration( + key: $fieldDefinition->getName(), + group: $definition->getGroup(), + sortable: true, + editable: !$fieldDefinition->getNoteditable(), + localizable: $definition->isLocalized(), + locale: null, + type: 'dataobject.' . $fieldDefinition->getFieldType(), + frontendType: $fieldDefinition->getFieldType(), + config: $options ? ['options' => $options] : [], + ); + } + /** * @param ColumnConfiguration[] $columns */ diff --git a/src/Grid/Service/ColumnConfigurationServiceInterface.php b/src/Grid/Service/ColumnConfigurationServiceInterface.php index 4ab7eace..1ee018c9 100644 --- a/src/Grid/Service/ColumnConfigurationServiceInterface.php +++ b/src/Grid/Service/ColumnConfigurationServiceInterface.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\StudioBackendBundle\Grid\Service; use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\ColumnConfiguration; +use Pimcore\Bundle\StudioBackendBundle\Grid\Util\ColumnFieldDefinition; /** * @internal @@ -32,4 +33,6 @@ public function getAvailableAssetColumnConfiguration(): array; * @return ColumnConfiguration[] */ public function getAvailableDataObjectColumnConfiguration(string $classId, int $folderId): array; + + public function buildColumnConfiguration(ColumnFieldDefinition $definition): ColumnConfiguration; }