Skip to content

Commit

Permalink
fix(quantityValue): Use null when no value was defined (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
smoothie authored Jul 19, 2024
1 parent 34e8dff commit 863b36e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/GraphQL/DataObjectInputProcessor/QuantityValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
$attribute = $this->getAttribute();
Service::setValue($object, $attribute, function ($container, $setter) use ($newValue) {
if ($newValue) {
$value = null;
$unit = null;
if (isset($newValue['value'])) {
$value = $newValue['value'];
}
if (isset($newValue['unitId'])) {
$unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getById($newValue['unitId']);
} elseif (isset($newValue['unit'])) {
$unit = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation($newValue['unit']);
}
$quantityValue = new \Pimcore\Model\DataObject\Data\QuantityValue($newValue['value'], $unit);
$quantityValue = new \Pimcore\Model\DataObject\Data\QuantityValue($value, $unit);

return $container->$setter($quantityValue);
}
Expand Down

0 comments on commit 863b36e

Please sign in to comment.