diff --git a/src/CustomReport/Controller/GetController.php b/src/CustomReport/Controller/GetController.php index 1bf39d2d..a674ae23 100644 --- a/src/CustomReport/Controller/GetController.php +++ b/src/CustomReport/Controller/GetController.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Controller; +use Exception; use OpenApi\Attributes\Get; use OpenApi\Attributes\JsonContent; use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\NameParameter; @@ -54,7 +55,7 @@ public function __construct( /** * @throws NotFoundException|DatabaseException - * @throws \Exception + * @throws Exception */ #[Route('/custom-reports/{name}', name: 'pimcore_studio_api_custom_report_get', @@ -90,9 +91,10 @@ public function __construct( public function getByName(string $name): JsonResponse { $config = $this->customReportService->getCustomReportByName($name); - if(!$config) { + if (!$config) { throw new NotFoundException('Custom report', $name, 'name'); } + return $this->jsonResponse( $this->customReportHydrator->hydrateCustomReportDetails($config) ); diff --git a/src/CustomReport/Hydrator/CustomReportHydrator.php b/src/CustomReport/Hydrator/CustomReportHydrator.php index 20833f4b..ef763b6a 100644 --- a/src/CustomReport/Hydrator/CustomReportHydrator.php +++ b/src/CustomReport/Hydrator/CustomReportHydrator.php @@ -60,10 +60,11 @@ public function hydrateCustomReportConfigTree(array $reports): array return $hydratedReports; } - public function hydrateCustomReportDetails(Config $reportConfig): array { + public function hydrateCustomReportDetails(Config $reportConfig): array + { return [ ... $reportConfig->getObjectVars(), - 'writeable' => $reportConfig->isWriteable() + 'writeable' => $reportConfig->isWriteable(), ]; } } diff --git a/src/CustomReport/Hydrator/CustomReportHydratorInterface.php b/src/CustomReport/Hydrator/CustomReportHydratorInterface.php index 3bb05abe..01e28a93 100644 --- a/src/CustomReport/Hydrator/CustomReportHydratorInterface.php +++ b/src/CustomReport/Hydrator/CustomReportHydratorInterface.php @@ -26,5 +26,6 @@ interface CustomReportHydratorInterface public function hydrateCustomReportTree(array $reports): array; public function hydrateCustomReportConfigTree(array $reports): array; + public function hydrateCustomReportDetails(Config $reportConfig): array; }