-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Task] Load chart data for custom reports (#681)
* Added endpoint for chart data * Apply php-cs-fixer changes * Added custom exceptions * Apply php-cs-fixer changes * Updated exception handling, added IntParameter * Apply php-cs-fixer changes * Added schema * Apply php-cs-fixer changes * Added doctype comment again to make phpstan happy * Apply php-cs-fixer changes * Added pre_response events * Apply php-cs-fixer changes * Parameter order * Naming * Added phpdocs for exception * Apply php-cs-fixer changes
- Loading branch information
Showing
28 changed files
with
892 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Controller\Chart; | ||
|
||
use Exception; | ||
use OpenApi\Attributes\Get; | ||
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\NameParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; | ||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\MappedParameter\ChartDataParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema\CustomReportChartData; | ||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Service\CustomReportServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\DatabaseException; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Content\ItemsJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\FilterParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\IntParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageSizeParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\SortOrderParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\StringParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\CustomReportPermissions; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpKernel\Attribute\MapQueryString; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class GetController extends AbstractApiController | ||
{ | ||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly CustomReportServiceInterface $customReportService | ||
) { | ||
parent::__construct($serializer); | ||
} | ||
|
||
/** | ||
* @throws NotFoundException|DatabaseException | ||
* @throws Exception | ||
*/ | ||
#[Route('/custom-reports/chart/{name}', | ||
name: 'pimcore_studio_api_custom_reports_chart', | ||
methods: ['GET']) | ||
] | ||
#[IsGranted(CustomReportPermissions::REPORTS->value)] | ||
#[Get( | ||
path: self::PREFIX . '/custom-reports/chart/{name}', | ||
operationId: 'custom_reports_chart', | ||
summary: 'custom_reports_chart_summary', | ||
tags: [Tags::CustomReports->value] | ||
)] | ||
#[NameParameter( | ||
name: 'name', | ||
description: 'custom_reports_chart_name_parameter', | ||
example: 'Quality_Attributes' | ||
)] | ||
#[PageParameter] | ||
#[PageSizeParameter] | ||
#[SortOrderParameter] | ||
#[StringParameter( | ||
name: 'sortBy', | ||
example: '', | ||
description: 'custom_reports_chart_sort_by_parameter', | ||
required: false | ||
)] | ||
#[FilterParameter('chart data')] | ||
#[IntParameter( | ||
name: 'reportOffset', | ||
description: 'custom_reports_chart_report_offset_parameter', | ||
required: false | ||
)] | ||
#[IntParameter( | ||
name: 'reportLimit', | ||
description: 'custom_reports_chart_report_limit_parameter', | ||
required: false | ||
)] | ||
#[SuccessResponse( | ||
description: 'custom_reports_chart_success_response', | ||
content: new ItemsJson(CustomReportChartData::class) | ||
)] | ||
#[DefaultResponses([ | ||
HttpResponseCodes::NOT_FOUND, | ||
])] | ||
public function getChartData( | ||
string $name, | ||
#[MapQueryString] ChartDataParameter $chartDataParameter | ||
): JsonResponse { | ||
return $this->jsonResponse( | ||
$this->customReportService->getChartData($name, $chartDataParameter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Event; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema\CustomReportChartData; | ||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
|
||
final class ChartDataEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.custom_report_chart_data'; | ||
|
||
public function __construct( | ||
private readonly CustomReportChartData $chartData | ||
) { | ||
parent::__construct($this->chartData); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getReport(): CustomReportChartData | ||
{ | ||
return $this->chartData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Event; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema\CustomReportDetails; | ||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
|
||
final class ReportEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.custom_report_report'; | ||
|
||
public function __construct( | ||
private readonly CustomReportDetails $report | ||
) { | ||
parent::__construct($this->report); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getReport(): CustomReportDetails | ||
{ | ||
return $this->report; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Event; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema\CustomReportTreeConfigNode; | ||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
|
||
final class TreeConfigNodeEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.custom_report_tree_config_node'; | ||
|
||
public function __construct( | ||
private readonly CustomReportTreeConfigNode $treeConfigNode | ||
) { | ||
parent::__construct($this->treeConfigNode); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getTreeConfigNode(): CustomReportTreeConfigNode | ||
{ | ||
return $this->treeConfigNode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Event; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema\CustomReportTreeNode; | ||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
|
||
final class TreeNodeEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.custom_report_tree_node'; | ||
|
||
public function __construct( | ||
private readonly CustomReportTreeNode $treeNode | ||
) { | ||
parent::__construct($this->treeNode); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getTreeNode(): CustomReportTreeNode | ||
{ | ||
return $this->treeNode; | ||
} | ||
} |
Oops, something went wrong.