From 9d901bb39dcb91266a2fa920f3d047d548252b37 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Wed, 27 Nov 2024 15:58:55 +0100 Subject: [PATCH 1/4] feat: add endpoints related to quantity value --- config/class.yaml | 5 + .../Attribute/Request/ConvertRequestBody.php | 34 ++++ .../Attribute/Response/ConvertedValueJson.php | 44 +++++ .../Response/QuantityValueUnitsJson.php | 43 +++++ .../QuantityValue/ConvertAllController.php | 88 ++++++++++ .../QuantityValue/ConvertController.php | 83 +++++++++ .../QuantityValue/UnitListController.php | 75 +++++++++ .../QuantityValueConversionEvent.php | 39 +++++ .../PreResponse/QuantityValueUnitEvent.php | 39 +++++ .../Repository/QuantityValueRepository.php | 53 ++++++ .../QuantityValueRepositoryInterface.php | 35 ++++ src/Class/Schema/ConvertAllParameters.php | 46 +++++ src/Class/Schema/ConvertParameters.php | 53 ++++++ src/Class/Schema/ConvertedQuantityValue.php | 57 +++++++ src/Class/Schema/ConvertedQuantityValues.php | 70 ++++++++ src/Class/Schema/QuantityValueUnit.php | 109 ++++++++++++ src/Class/Service/QuantityValueService.php | 159 ++++++++++++++++++ .../Service/QuantityValueServiceInterface.php | 45 +++++ translations/studio_api_docs.en.yaml | 15 +- 19 files changed, 1091 insertions(+), 1 deletion(-) create mode 100644 src/Class/Attribute/Request/ConvertRequestBody.php create mode 100644 src/Class/Attribute/Response/ConvertedValueJson.php create mode 100644 src/Class/Attribute/Response/QuantityValueUnitsJson.php create mode 100644 src/Class/Controller/QuantityValue/ConvertAllController.php create mode 100644 src/Class/Controller/QuantityValue/ConvertController.php create mode 100644 src/Class/Controller/QuantityValue/UnitListController.php create mode 100644 src/Class/Event/PreResponse/QuantityValueConversionEvent.php create mode 100644 src/Class/Event/PreResponse/QuantityValueUnitEvent.php create mode 100644 src/Class/Repository/QuantityValueRepository.php create mode 100644 src/Class/Repository/QuantityValueRepositoryInterface.php create mode 100644 src/Class/Schema/ConvertAllParameters.php create mode 100644 src/Class/Schema/ConvertParameters.php create mode 100644 src/Class/Schema/ConvertedQuantityValue.php create mode 100644 src/Class/Schema/ConvertedQuantityValues.php create mode 100644 src/Class/Schema/QuantityValueUnit.php create mode 100644 src/Class/Service/QuantityValueService.php create mode 100644 src/Class/Service/QuantityValueServiceInterface.php diff --git a/config/class.yaml b/config/class.yaml index 1de06806..e818c5e5 100644 --- a/config/class.yaml +++ b/config/class.yaml @@ -17,6 +17,11 @@ services: Pimcore\Bundle\StudioBackendBundle\Class\Service\FieldCollection\LayoutDefinitionServiceInterface: class: Pimcore\Bundle\StudioBackendBundle\Class\Service\FieldCollection\LayoutDefinitionService + Pimcore\Bundle\StudioBackendBundle\Class\Repository\QuantityValueRepositoryInterface: + class: Pimcore\Bundle\StudioBackendBundle\Class\Repository\QuantityValueRepository + + Pimcore\Bundle\StudioBackendBundle\Class\Service\QuantityValueServiceInterface: + class: Pimcore\Bundle\StudioBackendBundle\Class\Service\QuantityValueService # # Hydrators diff --git a/src/Class/Attribute/Request/ConvertRequestBody.php b/src/Class/Attribute/Request/ConvertRequestBody.php new file mode 100644 index 00000000..799e4800 --- /dev/null +++ b/src/Class/Attribute/Request/ConvertRequestBody.php @@ -0,0 +1,34 @@ +value)] + #[Post( + path: self::PREFIX . '/class/quantity-value/convert-all', + operationId: 'class_quantity_value_unit_convert_all', + description: 'class_quantity_value_unit_convert_all_description', + summary: 'class_quantity_value_unit_convert_all_summary', + tags: [Tags::ClassDefinition->value] + )] + #[SuccessResponse( + description: 'class_quantity_value_unit_convert_all_success_response', + content: new JsonContent(ref: ConvertedQuantityValues::class) + )] + #[ConvertRequestBody(ConvertAllParameters::class)] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND + ])] + public function get(#[MapRequestPayload] ConvertAllParameters $parameters): JsonResponse + { + return $this->jsonResponse($this->quantityValueService->convertAllUnits($parameters)); + } +} diff --git a/src/Class/Controller/QuantityValue/ConvertController.php b/src/Class/Controller/QuantityValue/ConvertController.php new file mode 100644 index 00000000..253cac32 --- /dev/null +++ b/src/Class/Controller/QuantityValue/ConvertController.php @@ -0,0 +1,83 @@ +value)] + #[Post( + path: self::PREFIX . '/class/quantity-value/convert', + operationId: 'class_quantity_value_unit_convert', + description: 'class_quantity_value_unit_convert_description', + summary: 'class_quantity_value_unit_convert_summary', + tags: [Tags::ClassDefinition->value] + )] + #[SuccessResponse( + description: 'class_quantity_value_unit_convert_success_response', + content: new ConvertedValueJson() + )] + #[ConvertRequestBody] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND + ])] + public function get(#[MapRequestPayload] ConvertParameters $parameters): JsonResponse + { + return $this->jsonResponse(['data' => $this->quantityValueService->convertUnit($parameters)]); + } +} diff --git a/src/Class/Controller/QuantityValue/UnitListController.php b/src/Class/Controller/QuantityValue/UnitListController.php new file mode 100644 index 00000000..afad3436 --- /dev/null +++ b/src/Class/Controller/QuantityValue/UnitListController.php @@ -0,0 +1,75 @@ +value)] + #[Get( + path: self::PREFIX . '/class/quantity-value/unit-list', + operationId: 'class_quantity_value_unit_list', + description: 'class_quantity_value_unit_list_description', + summary: 'class_quantity_value_unit_list_summary', + tags: [Tags::ClassDefinition->value] + )] + #[SuccessResponse( + description: 'class_quantity_value_unit_list_success_response', + content: new QuantityValueUnitsJson() + )] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] + public function listUnits(): JsonResponse + { + return $this->jsonResponse(['items' => $this->quantityValueService->listUnits()]); + } +} diff --git a/src/Class/Event/PreResponse/QuantityValueConversionEvent.php b/src/Class/Event/PreResponse/QuantityValueConversionEvent.php new file mode 100644 index 00000000..c9c0c15c --- /dev/null +++ b/src/Class/Event/PreResponse/QuantityValueConversionEvent.php @@ -0,0 +1,39 @@ +collection); + } + + /** + * Use this to get additional infos out of the response object + */ + public function getCollection(): ConvertedQuantityValues + { + return $this->collection; + } +} diff --git a/src/Class/Event/PreResponse/QuantityValueUnitEvent.php b/src/Class/Event/PreResponse/QuantityValueUnitEvent.php new file mode 100644 index 00000000..40f58c6b --- /dev/null +++ b/src/Class/Event/PreResponse/QuantityValueUnitEvent.php @@ -0,0 +1,39 @@ +unit); + } + + /** + * Use this to get additional infos out of the response object + */ + public function getUnit(): QuantityValueUnit + { + return $this->unit; + } +} diff --git a/src/Class/Repository/QuantityValueRepository.php b/src/Class/Repository/QuantityValueRepository.php new file mode 100644 index 00000000..541b86df --- /dev/null +++ b/src/Class/Repository/QuantityValueRepository.php @@ -0,0 +1,53 @@ +setOrderKey(['baseunit', 'factor', 'abbreviation']); + $list->setOrder(['ASC', 'ASC', 'ASC']); + + return $list->getUnits(); + } + + /** + * @return Unit[] + */ + public function getUnitListByBaseUnit(string $baseUnitId, string $fromUnitId): array + { + $list = new Listing(); + $list->setCondition( + 'baseunit = ' . $list->quote($baseUnitId) . + ' AND id != ' . $list->quote($fromUnitId) + ); + + return $list->getUnits(); + } +} diff --git a/src/Class/Repository/QuantityValueRepositoryInterface.php b/src/Class/Repository/QuantityValueRepositoryInterface.php new file mode 100644 index 00000000..f68f2651 --- /dev/null +++ b/src/Class/Repository/QuantityValueRepositoryInterface.php @@ -0,0 +1,35 @@ +fromUnitId; + } + + public function getValue(): float|int + { + return $this->value; + } +} diff --git a/src/Class/Schema/ConvertParameters.php b/src/Class/Schema/ConvertParameters.php new file mode 100644 index 00000000..d63d0c04 --- /dev/null +++ b/src/Class/Schema/ConvertParameters.php @@ -0,0 +1,53 @@ +fromUnitId; + } + + public function getToUnitId(): string + { + return $this->toUnitId; + } + + public function getValue(): float|int + { + return $this->value; + } +} diff --git a/src/Class/Schema/ConvertedQuantityValue.php b/src/Class/Schema/ConvertedQuantityValue.php new file mode 100644 index 00000000..62301f62 --- /dev/null +++ b/src/Class/Schema/ConvertedQuantityValue.php @@ -0,0 +1,57 @@ +unitAbbreviation; + } + + public function getUnitLongName(): string + { + return $this->unitLongName; + } + + public function getConvertedValue(): float + { + return $this->convertedValue; + } +} diff --git a/src/Class/Schema/ConvertedQuantityValues.php b/src/Class/Schema/ConvertedQuantityValues.php new file mode 100644 index 00000000..ec42494e --- /dev/null +++ b/src/Class/Schema/ConvertedQuantityValues.php @@ -0,0 +1,70 @@ +originalValue; + } + + public function getFromUnitId(): string + { + return $this->fromUnitId; + } + + public function getConvertedValues(): array + { + return $this->convertedValues; + } +} diff --git a/src/Class/Schema/QuantityValueUnit.php b/src/Class/Schema/QuantityValueUnit.php new file mode 100644 index 00000000..075cc4d8 --- /dev/null +++ b/src/Class/Schema/QuantityValueUnit.php @@ -0,0 +1,109 @@ +id; + } + + public function getAbbreviation(): ?string + { + return $this->abbreviation; + } + + public function getGroup(): ?string + { + return $this->group; + } + + public function getLongName(): ?string + { + return $this->longName; + } + + public function getBaseUnit(): ?string + { + return $this->baseUnit; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function getFactor(): ?float + { + return $this->factor; + } + + public function getConversionOffset(): ?float + { + return $this->conversionOffset; + } + + public function getConverter(): ?string + { + return $this->converter; + } +} diff --git a/src/Class/Service/QuantityValueService.php b/src/Class/Service/QuantityValueService.php new file mode 100644 index 00000000..15537816 --- /dev/null +++ b/src/Class/Service/QuantityValueService.php @@ -0,0 +1,159 @@ +quantityValueRepository->getUnitList(); + $units = []; + + foreach ($listing as $unit) { + $quantityValueUnit = new QuantityValueUnit( + $unit->getId(), + $unit->getAbbreviation(), + $unit->getGroup(), + $unit->getLongname(), + $unit->getBaseunit() ? $unit->getBaseunit()->getId() : null, + $unit->getReference(), + $unit->getFactor(), + $unit->getConversionOffset(), + $unit->getConverter() + ); + + $this->eventDispatcher->dispatch( + new QuantityValueUnitEvent($quantityValueUnit), + QuantityValueUnitEvent::EVENT_NAME + ); + + $units[] = $quantityValueUnit; + } + + return $units; + } + + /** + * @throws DatabaseException|NotFoundException + */ + public function convertUnit(ConvertParameters $parameters): float|int + { + return $this->getConvertedValue( + $this->getUnit($parameters->getFromUnitId()), + $this->getUnit($parameters->getToUnitId()), + $parameters->getValue() + ); + } + + /** + * @throws DatabaseException|NotFoundException + */ + public function convertAllUnits(ConvertAllParameters $parameters): ConvertedQuantityValues + { + $fromUnit = $this->getUnit($parameters->getFromUnitId()); + $baseUnit = $fromUnit->getBaseunit() ?? $fromUnit; + $toUnits = $this->quantityValueRepository->getUnitListByBaseUnit($baseUnit->getId(), $fromUnit->getId()); + + $convertedValues = []; + foreach ($toUnits as $toUnit) { + $convertedValue = $this->getConvertedValue($fromUnit, $toUnit, $parameters->getValue()); + $convertedValues[] = new ConvertedQuantityValue( + $toUnit->getAbbreviation(), + $toUnit->getLongname(), + round($convertedValue, 4) + ); + } + + $collection = new ConvertedQuantityValues( + $parameters->getValue(), + $parameters->getFromUnitId(), + $convertedValues + ); + + $this->eventDispatcher->dispatch( + new QuantityValueConversionEvent($collection), + QuantityValueConversionEvent::EVENT_NAME + ); + + return $collection; + } + + /** + * @throws NotFoundException + */ + private function getUnit(string $unitId): Unit + { + $unit = $this->unitResolver->getById($unitId); + + if ($unit === null) { + throw new NotFoundException('Unit', $unitId); + } + + return $unit; + } + + /** + * @throws DatabaseException + */ + private function getConvertedValue(Unit $fromUnit, Unit $toUnit, float|int $value ): float|int + { + try { + $convertedValue = $this->unitConversionService->convert( + new QuantityValue($value, $fromUnit), + $toUnit + ); + } catch (Exception $exception) { + throw new DatabaseException( + sprintf('Could not convert unit "%s" to "%s": %s', $fromUnit, $toUnit, $exception->getMessage()) + ); + } + + return $convertedValue->getValue(); + } + +} diff --git a/src/Class/Service/QuantityValueServiceInterface.php b/src/Class/Service/QuantityValueServiceInterface.php new file mode 100644 index 00000000..553005f8 --- /dev/null +++ b/src/Class/Service/QuantityValueServiceInterface.php @@ -0,0 +1,45 @@ +{value} from one unit to another based on the given {fromUnitId} and {toUnitId} +class_quantity_value_unit_convert_summary: Convert quantity value from one unit to another +class_quantity_value_unit_convert_success_response: Converted quantity value +class_quantity_value_unit_convert_all_description: | + Convert quantity {value} from one unit to all other available units based on the given {fromUnitId}.
+ Units have to have {fromUnitId} defined as base unit to be considered for conversion. +class_quantity_value_unit_convert_all_summary: Convert quantity value from one unit to all other related units +class_quantity_value_unit_convert_all_success_response: Converted quantity value \ No newline at end of file From 38fb6020342abb7bef0149c75e7aa49a687f7052 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Wed, 27 Nov 2024 15:01:13 +0000 Subject: [PATCH 2/4] Apply php-cs-fixer changes --- src/Class/Controller/QuantityValue/ConvertAllController.php | 4 +--- src/Class/Controller/QuantityValue/ConvertController.php | 2 +- src/Class/Controller/QuantityValue/UnitListController.php | 4 +--- src/Class/Repository/QuantityValueRepository.php | 1 - src/Class/Schema/ConvertedQuantityValue.php | 2 +- src/Class/Schema/ConvertedQuantityValues.php | 2 +- src/Class/Schema/QuantityValueUnit.php | 2 +- src/Class/Service/QuantityValueService.php | 6 +++--- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Class/Controller/QuantityValue/ConvertAllController.php b/src/Class/Controller/QuantityValue/ConvertAllController.php index c9b07087..6ecf4d74 100644 --- a/src/Class/Controller/QuantityValue/ConvertAllController.php +++ b/src/Class/Controller/QuantityValue/ConvertAllController.php @@ -21,14 +21,12 @@ use Pimcore\Bundle\StudioBackendBundle\Class\Attribute\Request\ConvertRequestBody; use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ConvertAllParameters; use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ConvertedQuantityValues; -use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ConvertParameters; use Pimcore\Bundle\StudioBackendBundle\Class\Service\QuantityValueServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\AccessDeniedException; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\DatabaseException; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\DataJson; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; @@ -79,7 +77,7 @@ public function __construct( #[ConvertRequestBody(ConvertAllParameters::class)] #[DefaultResponses([ HttpResponseCodes::UNAUTHORIZED, - HttpResponseCodes::NOT_FOUND + HttpResponseCodes::NOT_FOUND, ])] public function get(#[MapRequestPayload] ConvertAllParameters $parameters): JsonResponse { diff --git a/src/Class/Controller/QuantityValue/ConvertController.php b/src/Class/Controller/QuantityValue/ConvertController.php index 253cac32..1b8aa4a7 100644 --- a/src/Class/Controller/QuantityValue/ConvertController.php +++ b/src/Class/Controller/QuantityValue/ConvertController.php @@ -74,7 +74,7 @@ public function __construct( #[ConvertRequestBody] #[DefaultResponses([ HttpResponseCodes::UNAUTHORIZED, - HttpResponseCodes::NOT_FOUND + HttpResponseCodes::NOT_FOUND, ])] public function get(#[MapRequestPayload] ConvertParameters $parameters): JsonResponse { diff --git a/src/Class/Controller/QuantityValue/UnitListController.php b/src/Class/Controller/QuantityValue/UnitListController.php index afad3436..b6e26905 100644 --- a/src/Class/Controller/QuantityValue/UnitListController.php +++ b/src/Class/Controller/QuantityValue/UnitListController.php @@ -20,8 +20,6 @@ use Pimcore\Bundle\StudioBackendBundle\Class\Attribute\Response\QuantityValueUnitsJson; use Pimcore\Bundle\StudioBackendBundle\Class\Service\QuantityValueServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; -use Pimcore\Bundle\StudioBackendBundle\Exception\Api\AccessDeniedException; -use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; @@ -66,7 +64,7 @@ public function __construct( content: new QuantityValueUnitsJson() )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED + HttpResponseCodes::UNAUTHORIZED, ])] public function listUnits(): JsonResponse { diff --git a/src/Class/Repository/QuantityValueRepository.php b/src/Class/Repository/QuantityValueRepository.php index 541b86df..8ec69aef 100644 --- a/src/Class/Repository/QuantityValueRepository.php +++ b/src/Class/Repository/QuantityValueRepository.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioBackendBundle\Class\Repository; - use Pimcore\Model\DataObject\QuantityValue\Unit; use Pimcore\Model\DataObject\QuantityValue\Unit\Listing; diff --git a/src/Class/Schema/ConvertedQuantityValue.php b/src/Class/Schema/ConvertedQuantityValue.php index 62301f62..900d8fea 100644 --- a/src/Class/Schema/ConvertedQuantityValue.php +++ b/src/Class/Schema/ConvertedQuantityValue.php @@ -24,7 +24,7 @@ required: [ 'originalValue', 'fromUnitId', - 'convertedValues' + 'convertedValues', ], type: 'object' )] diff --git a/src/Class/Schema/ConvertedQuantityValues.php b/src/Class/Schema/ConvertedQuantityValues.php index ec42494e..7b70c494 100644 --- a/src/Class/Schema/ConvertedQuantityValues.php +++ b/src/Class/Schema/ConvertedQuantityValues.php @@ -27,7 +27,7 @@ required: [ 'originalValue', 'fromUnitId', - 'convertedValues' + 'convertedValues', ], type: 'object' )] diff --git a/src/Class/Schema/QuantityValueUnit.php b/src/Class/Schema/QuantityValueUnit.php index 075cc4d8..288ebc13 100644 --- a/src/Class/Schema/QuantityValueUnit.php +++ b/src/Class/Schema/QuantityValueUnit.php @@ -61,7 +61,7 @@ public function __construct( private readonly ?string $converter, ) { } - + public function getId(): ?string { return $this->id; diff --git a/src/Class/Service/QuantityValueService.php b/src/Class/Service/QuantityValueService.php index 15537816..3c602838 100644 --- a/src/Class/Service/QuantityValueService.php +++ b/src/Class/Service/QuantityValueService.php @@ -32,6 +32,7 @@ use Pimcore\Model\DataObject\QuantityValue\Unit; use Pimcore\Model\DataObject\QuantityValue\UnitConversionService; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use function sprintf; /** * @internal @@ -80,7 +81,7 @@ public function listUnits(): array /** * @throws DatabaseException|NotFoundException - */ + */ public function convertUnit(ConvertParameters $parameters): float|int { return $this->getConvertedValue( @@ -140,7 +141,7 @@ private function getUnit(string $unitId): Unit /** * @throws DatabaseException */ - private function getConvertedValue(Unit $fromUnit, Unit $toUnit, float|int $value ): float|int + private function getConvertedValue(Unit $fromUnit, Unit $toUnit, float|int $value): float|int { try { $convertedValue = $this->unitConversionService->convert( @@ -155,5 +156,4 @@ private function getConvertedValue(Unit $fromUnit, Unit $toUnit, float|int $valu return $convertedValue->getValue(); } - } From 67a6fd1fccabf8262a354797b26db6d5db1cfae0 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Thu, 28 Nov 2024 07:45:10 +0100 Subject: [PATCH 3/4] add changes from review --- src/Class/Controller/QuantityValue/ConvertAllController.php | 4 ++-- src/Class/Controller/QuantityValue/ConvertController.php | 2 +- src/Class/Repository/QuantityValueRepository.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Class/Controller/QuantityValue/ConvertAllController.php b/src/Class/Controller/QuantityValue/ConvertAllController.php index 6ecf4d74..d88e866d 100644 --- a/src/Class/Controller/QuantityValue/ConvertAllController.php +++ b/src/Class/Controller/QuantityValue/ConvertAllController.php @@ -55,7 +55,7 @@ public function __construct( } /** - * @throws AccessDeniedException|DatabaseException|NotFoundException|UserNotFoundException + * @throws DatabaseException|NotFoundException */ #[Route( '/class/quantity-value/convert-all', @@ -79,7 +79,7 @@ public function __construct( HttpResponseCodes::UNAUTHORIZED, HttpResponseCodes::NOT_FOUND, ])] - public function get(#[MapRequestPayload] ConvertAllParameters $parameters): JsonResponse + public function covertAll(#[MapRequestPayload] ConvertAllParameters $parameters): JsonResponse { return $this->jsonResponse($this->quantityValueService->convertAllUnits($parameters)); } diff --git a/src/Class/Controller/QuantityValue/ConvertController.php b/src/Class/Controller/QuantityValue/ConvertController.php index 1b8aa4a7..b68fd81f 100644 --- a/src/Class/Controller/QuantityValue/ConvertController.php +++ b/src/Class/Controller/QuantityValue/ConvertController.php @@ -76,7 +76,7 @@ public function __construct( HttpResponseCodes::UNAUTHORIZED, HttpResponseCodes::NOT_FOUND, ])] - public function get(#[MapRequestPayload] ConvertParameters $parameters): JsonResponse + public function convert(#[MapRequestPayload] ConvertParameters $parameters): JsonResponse { return $this->jsonResponse(['data' => $this->quantityValueService->convertUnit($parameters)]); } diff --git a/src/Class/Repository/QuantityValueRepository.php b/src/Class/Repository/QuantityValueRepository.php index 8ec69aef..9d01939d 100644 --- a/src/Class/Repository/QuantityValueRepository.php +++ b/src/Class/Repository/QuantityValueRepository.php @@ -22,7 +22,7 @@ /** * @internal */ -class QuantityValueRepository implements QuantityValueRepositoryInterface +final readonly class QuantityValueRepository implements QuantityValueRepositoryInterface { /** * @return Unit[] From 998b33d25ad73009caca5ad4005a3ac148cc8d0d Mon Sep 17 00:00:00 2001 From: lukmzig Date: Thu, 28 Nov 2024 06:45:43 +0000 Subject: [PATCH 4/4] Apply php-cs-fixer changes --- src/Class/Controller/QuantityValue/ConvertAllController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Class/Controller/QuantityValue/ConvertAllController.php b/src/Class/Controller/QuantityValue/ConvertAllController.php index d88e866d..ea0e703e 100644 --- a/src/Class/Controller/QuantityValue/ConvertAllController.php +++ b/src/Class/Controller/QuantityValue/ConvertAllController.php @@ -23,10 +23,8 @@ use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ConvertedQuantityValues; use Pimcore\Bundle\StudioBackendBundle\Class\Service\QuantityValueServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; -use Pimcore\Bundle\StudioBackendBundle\Exception\Api\AccessDeniedException; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\DatabaseException; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; -use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;