/** * @param DeliveryInterface $delivery * @param ExtractorResult $extractorResult */ private function copyValue(DeliveryInterface $delivery, ExtractorResult $extractorResult) { switch ($extractorResult->getPropertyName()) { case TransformerProperties::DELIVERY_RECIPIENT_PHONE: $delivery->setRecipientPhone($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_RECIPIENT_NAME: $delivery->setRecipientName($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_RECIPIENT_EMAIL: $delivery->setRecipientEmail($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_POSTAL_CODE: $delivery->setPostalCode($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_CITY: $delivery->setCity($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_COUNTRY_CODE: $delivery->setCountryCode($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_NAME: $delivery->setName($extractorResult->getValue()); break; case TransformerProperties::DELIVERY_STREET: $delivery->setStreet($extractorResult->getValue()); break; default: } }
/** * @inheritdoc */ public function transform(OrderInterface $order, ExtractorResult $extractorResult) { $usersProductCollection = $extractorResult->getValue(); $this->checkProductCollection($usersProductCollection); foreach ($usersProductCollection as $userProduct) { $order->getProductCollection()->addProduct($this->singleProductTransformer->transform($userProduct)); } return $order; }
/** * @inheritdoc */ public function transform(OrderInterface $order, ExtractorResult $extractorResult) { /** @var \Traversable $shippingMethodCollection */ $shippingMethodCollection = $extractorResult->getValue(); $this->checkCollection($shippingMethodCollection); foreach ($shippingMethodCollection as $usersShippingMethod) { $order->getShippingMethodCollection()->addShippingMethod($this->singleShippingMethodTransformer->transform($usersShippingMethod)); } }
public function it_should_call_helper(SingleShippingMethodTransformer $singleShippingMethodTransformer, ExtractorResult $extractorResult, OrderInterface $order, \stdClass $usersShippingMethod) { $extractorResult->getValue()->willReturn([$usersShippingMethod]); $extractorResult->getValue()->shouldBeCalledTimes(1); $order->getShippingMethodCollection()->willReturn(new ShippingMethodCollection()); $order->getShippingMethodCollection()->shouldBeCalledTimes(1); $singleShippingMethodTransformer->transform($usersShippingMethod)->willReturn(new ShippingMethod()); $singleShippingMethodTransformer->transform($usersShippingMethod)->shouldBeCalledTimes(1); $this->transform($order, $extractorResult); }
/** * @param ProductInterface $product * @param ExtractorResult $extractionResult */ private function transformParameter(ProductInterface $product, ExtractorResult $extractionResult) { switch ($extractionResult->getPropertyName()) { case TransformerProperties::PRODUCT_UNIT_PRICE: $product->setUnitPrice($extractionResult->getValue()); break; case TransformerProperties::PRODUCT_QUANTITY: $product->setQuantity($extractionResult->getValue()); break; case TransformerProperties::PRODUCT_NAME: $product->setName($extractionResult->getValue()); break; default: } }
/** * @param OrderInterface $order * @param ExtractorResult $extractorResult */ private function copyValue(OrderInterface $order, ExtractorResult $extractorResult) { switch ($extractorResult->getPropertyName()) { case TransformerProperties::URLS_NOTIFY: $order->setNotifyUrl($extractorResult->getValue()); break; case TransformerProperties::URLS_CONTINUE: $order->setContinueUrl($extractorResult->getValue()); break; case TransformerProperties::URLS_ORDER: $order->setOrderUrl($extractorResult->getValue()); break; default: } }
/** * @param ShippingMethodInterface $shippingMethod * @param ExtractorResult $extractorResult */ protected function copyValue(ShippingMethodInterface $shippingMethod, ExtractorResult $extractorResult) { switch ($extractorResult->getPropertyName()) { case TransformerProperties::SHIPPING_METHOD_NAME: $shippingMethod->setName($extractorResult->getValue()); break; case TransformerProperties::SHIPPING_METHOD_PRICE: $shippingMethod->setPrice($extractorResult->getValue()); break; case TransformerProperties::SHIPPING_METHOD_COUNTRY: $shippingMethod->setCountry($extractorResult->getValue()); break; default: } }
/** * @param BuyerInterface $buyer * @param ExtractorResult $extractorResult */ private function copyValue(BuyerInterface $buyer, ExtractorResult $extractorResult) { switch ($extractorResult->getPropertyName()) { case TransformerProperties::BUYER_EMAIL: $buyer->setEmail($extractorResult->getValue()); break; case TransformerProperties::BUYER_PHONE: $buyer->setPhone($extractorResult->getValue()); break; case TransformerProperties::BUYER_FIRST_NAME: $buyer->setFirstName($extractorResult->getValue()); break; case TransformerProperties::BUYER_LAST_NAME: $buyer->setLastName($extractorResult->getValue()); break; default: } }
/** * @inheritdoc */ public function transform(OrderInterface $order, ExtractorResult $extractorResult) { $this->copyValue($order, $extractorResult->getPropertyName(), $extractorResult->getValue()); }
public function it_should_get_property_name_from_extractor(OrderInterface $order, ExtractorResult $extractorResult) { $extractorResult->getPropertyName()->shouldBeCalled(); $this->transform($order, $extractorResult); }
public function it_should_pass_value_to_main_transformer(UserOrderTransformerInterface $userOrderTransformer, OrderInterface $order, ExtractorResult $extractorResult, \stdClass $extractionValue) { $extractorResult->getValue()->willReturn($extractionValue); $userOrderTransformer->transform($order, $extractionValue)->shouldBeCalledTimes(1); $this->transform($order, $extractorResult); }
/** * @inheritdoc */ public function transform(OrderInterface $order, ExtractorResult $extractorResult) { $this->transformer->transform($order, $extractorResult->getValue()); }
/** * @inheritdoc */ public function transform(OrderInterface $order, ExtractorResult $extractorResult) { $this->copyValue($order->getBuyer()->getInvoice(), $extractorResult->getPropertyName(), $extractorResult->getValue())->copyRecipientValue($order->getBuyer()->getInvoice(), $extractorResult->getPropertyName(), $extractorResult->getValue()); }
/** * @param ExtractorResult $extractorResult * @param object $object */ private function logExtractedResult(ExtractorResult $extractorResult, $object) { $this->logger->debug(sprintf('Successfully extracted parameter %s with value "%s" from object %s', $extractorResult->getPropertyName(), print_r($extractorResult->getValue(), true), get_class($object))); }