diff --git a/config/pimcore/routing.yaml b/config/pimcore/routing.yaml index 2237f9d7c..48d30aabc 100644 --- a/config/pimcore/routing.yaml +++ b/config/pimcore/routing.yaml @@ -1,5 +1,10 @@ pimcore_studio_ui: - resource: "@PimcoreStudioUiBundle/src/Controller/" + resource: "@PimcoreStudioUiBundle/src/Controller/DefaultController.php" type: annotation prefix: '%pimcore_studio_ui.url_path%' +pimcore_studio_ui_backend: + resource: "@PimcoreStudioUiBundle/src/Controller/ImageEditorController.php" + type: annotation + prefix: '%pimcore_studio_backend.url_prefix%' + diff --git a/src/Controller/ImageEditorController.php b/src/Controller/ImageEditorController.php new file mode 100644 index 000000000..2bf3b2f1f --- /dev/null +++ b/src/Controller/ImageEditorController.php @@ -0,0 +1,85 @@ +get('id')); + + if (!$asset) { + throw $this->createNotFoundException('Asset not found'); + } + + $this->securityService->hasElementPermission( + $asset, + $this->securityService->getCurrentUser(), + ElementPermissions::VIEW_PERMISSION + ); + + + return $this->render('@PimcoreStudioUi/image-editor/editor.html.twig', [ + 'asset' => $asset + ]); + } + + #[Route('/get-asset', name: 'studio_temp_get_asset', methods: ['GET'])] + public function getAssetAction(Request $request): StreamedResponse + { + $image = Asset::getById((int)$request->get('id')); + + if (!$image) { + throw $this->createNotFoundException('Asset not found'); + } + + $this->securityService->hasElementPermission( + $image, + $this->securityService->getCurrentUser(), + ElementPermissions::VIEW_PERMISSION + ); + + $stream = $image->getStream(); + + if (!is_resource($stream)) { + throw $this->createNotFoundException('Unable to get resource for asset ' . $image->getId()); + } + + return new StreamedResponse(function () use ($stream) { + fpassthru($stream); + }, 200, [ + 'Content-Type' => $image->getMimeType(), + 'Access-Control-Allow-Origin' => '*', + ]); + } +} diff --git a/templates/image-editor/editor.html.twig b/templates/image-editor/editor.html.twig new file mode 100644 index 000000000..b8afa50fe --- /dev/null +++ b/templates/image-editor/editor.html.twig @@ -0,0 +1,200 @@ + + +
+ + + +