/** * @param \Generated\Shared\Transfer\DiscountCalculatorTransfer|null $value * * @return \Generated\Shared\Transfer\DiscountCalculatorTransfer|null */ public function reverseTransform($value) { if (!$value || !$value->getCalculatorPlugin()) { return null; } $calculatorPlugin = $this->getCalculatorPlugin($value->getCalculatorPlugin()); $transformedAmount = $calculatorPlugin->transformForPersistence($value->getAmount()); $value->setAmount($transformedAmount); return $value; }
/** * @return \Generated\Shared\Transfer\DiscountCalculatorTransfer */ protected function createDiscountCalculatorTransfer() { $calculatedDiscountTransfer = new DiscountCalculatorTransfer(); $calculatedDiscountTransfer->setCalculatorPlugin(DiscountDependencyProvider::PLUGIN_CALCULATOR_FIXED); return $calculatedDiscountTransfer; }
/** * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity * * @return \Generated\Shared\Transfer\DiscountCalculatorTransfer */ protected function hydrateDiscountCalculator(SpyDiscount $discountEntity) { $discountCalculatorTransfer = new DiscountCalculatorTransfer(); $discountCalculatorTransfer->fromArray($discountEntity->toArray(), true); return $discountCalculatorTransfer; }