1414namespace Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \Controller \Config ;
1515
1616use OpenApi \Attributes \Get ;
17- use Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \Schema \CustomReportTreeConfigNode ;
18- use Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \Service \CustomReportServiceInterface ;
17+ use Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \Attribute \Response \Property \AnyOfCustomReportNodes ;
18+ use Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \MappedParameter \TreeParameter ;
19+ use Pimcore \Bundle \StudioBackendBundle \Bundle \CustomReport \Service \CustomReportConfigServiceInterface ;
1920use Pimcore \Bundle \StudioBackendBundle \Controller \AbstractApiController ;
20- use Pimcore \Bundle \StudioBackendBundle \Exception \Api \InvalidQueryTypeException ;
21- use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Content \ItemsJson ;
22- use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Parameter \Query \PageParameter ;
23- use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Parameter \Query \PageSizeParameter ;
21+ use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Parameter \Query \BoolParameter ;
22+ use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Response \Content \CollectionJson ;
2423use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Response \DefaultResponses ;
2524use Pimcore \Bundle \StudioBackendBundle \OpenApi \Attribute \Response \SuccessResponse ;
2625use Pimcore \Bundle \StudioBackendBundle \OpenApi \Config \Tags ;
2726use Pimcore \Bundle \StudioBackendBundle \Util \Constant \CustomReportPermissions ;
2827use Pimcore \Bundle \StudioBackendBundle \Util \Constant \HttpResponseCodes ;
2928use Pimcore \Bundle \StudioBackendBundle \Util \Trait \PaginatedResponseTrait ;
3029use Symfony \Component \HttpFoundation \JsonResponse ;
30+ use Symfony \Component \HttpKernel \Attribute \MapQueryString ;
3131use Symfony \Component \Routing \Attribute \Route ;
3232use Symfony \Component \Security \Http \Attribute \IsGranted ;
3333use Symfony \Component \Serializer \SerializerInterface ;
@@ -44,14 +44,11 @@ final class TreeController extends AbstractApiController
4444
4545 public function __construct (
4646 SerializerInterface $ serializer ,
47- private readonly CustomReportServiceInterface $ customReportService ,
47+ private readonly CustomReportConfigServiceInterface $ customReportConfigService ,
4848 ) {
4949 parent ::__construct ($ serializer );
5050 }
5151
52- /**
53- * @throws InvalidQueryTypeException
54- */
5552 #[Route(self ::ROUTE , name: 'pimcore_studio_api_custom_reports_tree_config ' , methods: ['GET ' ])]
5653 #[IsGranted(CustomReportPermissions::REPORTS_CONFIG ->value )]
5754 #[Get(
@@ -61,18 +58,23 @@ public function __construct(
6158 summary: 'custom_reports_config_get_tree_summary ' ,
6259 tags: [Tags::BundleCustomReports->value ]
6360 )]
64- #[PageParameter]
65- #[PageSizeParameter]
61+ #[BoolParameter(
62+ 'withGroup ' ,
63+ description: 'Whether to group the results by report group. ' ,
64+ required: false ,
65+ example: false
66+ )]
6667 #[SuccessResponse(
67- description: 'custom_reports_get_tree_success_response ' ,
68- content: new ItemsJson (CustomReportTreeConfigNode::class )
68+ description: 'custom_reports_config_get_tree_success_response ' ,
69+ content: new CollectionJson ( new AnyOfCustomReportNodes () )
6970 )]
7071 #[DefaultResponses([
7172 HttpResponseCodes::UNAUTHORIZED ,
7273 ])]
73- public function getCustomReports (): JsonResponse
74- {
75- $ items = $ this ->customReportService ->getCustomReportConfigTree ();
74+ public function getCustomReports (
75+ #[MapQueryString] TreeParameter $ parameters = new TreeParameter ()
76+ ): JsonResponse {
77+ $ items = $ this ->customReportConfigService ->getCustomReportConfigTree ($ parameters ->isWithGroup ());
7678
7779 return $ this ->getPaginatedCollection ($ this ->serializer , $ items , count ($ items ));
7880 }
0 commit comments