Skip to content

Commit

Permalink
Merge pull request #848 from dpfaffenbauer/order-document-item-transf…
Browse files Browse the repository at this point in the history
…ormer-options

[Order] introduce options for order-document-items
  • Loading branch information
dpfaffenbauer authored Mar 4, 2019
2 parents 4e46b27 + 32c61f8 commit 59900dd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ interface OrderDocumentItemTransformerInterface
* @param OrderItemInterface $orderItem
* @param OrderDocumentItemInterface $documentItem
* @param int $quantity
* @param array $options
*
* @return OrderDocumentItemInterface
*/
public function transform(OrderDocumentInterface $orderDocument, OrderItemInterface $orderItem, OrderDocumentItemInterface $documentItem, $quantity);
public function transform(OrderDocumentInterface $orderDocument, OrderItemInterface $orderItem, OrderDocumentItemInterface $documentItem, $quantity, $options = []);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function transform(OrderDocumentInterface $invoice, OrderItemInterface $orderItem, OrderDocumentItemInterface $invoiceItem, $quantity)
public function transform(OrderDocumentInterface $invoice, OrderItemInterface $orderItem, OrderDocumentItemInterface $invoiceItem, $quantity, $options = [])
{
/**
* @var OrderInvoiceInterface $invoice
Expand All @@ -67,7 +67,16 @@ public function transform(OrderDocumentInterface $invoice, OrderItemInterface $o
Assert::isInstanceOf($invoice, OrderDocumentInterface::class);
Assert::isInstanceOf($invoiceItem, OrderInvoiceItemInterface::class);

$this->eventDispatcher->dispatchPreEvent('invoice_item', $invoiceItem, ['invoice' => $invoice, 'order' => $orderItem->getOrder(), 'order_item' => $orderItem]);
$this->eventDispatcher->dispatchPreEvent(
'invoice_item',
$invoiceItem,
[
'invoice' => $invoice,
'order' => $orderItem->getOrder(),
'order_item' => $orderItem,
'options' => $options
]
);

$itemFolder = $this->objectService->createFolderByPath($invoice->getFullPath() . '/' . $this->pathForItems);

Expand All @@ -88,7 +97,16 @@ public function transform(OrderDocumentInterface $invoice, OrderItemInterface $o
$invoiceItem->save();
}, false);

$this->eventDispatcher->dispatchPostEvent('invoice_item', $invoiceItem, ['invoice' => $invoice, 'order' => $orderItem->getOrder(), 'order_item' => $orderItem]);
$this->eventDispatcher->dispatchPostEvent(
'invoice_item',
$invoiceItem,
[
'invoice' => $invoice,
'order' => $orderItem->getOrder(),
'order_item' => $orderItem,
'options' => $options
]
);

return $invoiceItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function transform(OrderDocumentInterface $shipment, OrderItemInterface $orderItem, OrderDocumentItemInterface $shipmentItem, $quantity)
public function transform(OrderDocumentInterface $shipment, OrderItemInterface $orderItem, OrderDocumentItemInterface $shipmentItem, $quantity, $options = [])
{
/**
* @var OrderInvoiceInterface $shipment
Expand All @@ -67,7 +67,16 @@ public function transform(OrderDocumentInterface $shipment, OrderItemInterface $
Assert::isInstanceOf($shipment, OrderDocumentInterface::class);
Assert::isInstanceOf($shipmentItem, OrderShipmentItemInterface::class);

$this->eventDispatcher->dispatchPreEvent('shipment_item', $shipmentItem, ['shipment' => $shipment, 'order' => $orderItem->getOrder(), 'order_item' => $orderItem]);
$this->eventDispatcher->dispatchPreEvent(
'shipment_item',
$shipmentItem,
[
'shipment' => $shipment,
'order' => $orderItem->getOrder(),
'order_item' => $orderItem,
'options' => $options
]
);

$itemFolder = $this->objectService->createFolderByPath($shipment->getFullPath() . '/' . $this->pathForItems);

Expand All @@ -89,7 +98,16 @@ public function transform(OrderDocumentInterface $shipment, OrderItemInterface $
$shipmentItem->save();
}, false);

$this->eventDispatcher->dispatchPostEvent('shipment_item', $shipmentItem, ['shipment' => $shipment, 'order' => $orderItem->getOrder(), 'order_item' => $orderItem]);
$this->eventDispatcher->dispatchPostEvent(
'shipment_item',
$shipmentItem,
[
'shipment' => $shipment,
'order' => $orderItem->getOrder(),
'order_item' => $orderItem,
'options' => $options
]
);

return $shipmentItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,13 @@ public function transform(OrderInterface $order, OrderDocumentInterface $invoice
$quantity = $item['quantity'];

if ($orderItem instanceof OrderItemInterface) {
$items[] = $this->orderItemToInvoiceItemTransformer->transform($invoice, $orderItem, $invoiceItem, $quantity);
$items[] = $this->orderItemToInvoiceItemTransformer->transform(
$invoice,
$orderItem,
$invoiceItem,
$quantity,
$item
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ public function transform(OrderInterface $order, OrderDocumentInterface $shipmen
$quantity = $item['quantity'];

if ($orderItem instanceof OrderItemInterface) {
$items[] = $this->orderItemToShipmentItemTransformer->transform($shipment, $orderItem, $shipmentItem, $quantity);
$items[] = $this->orderItemToShipmentItemTransformer->transform(
$shipment,
$orderItem,
$shipmentItem,
$quantity,
$item
);
}
}

Expand Down

0 comments on commit 59900dd

Please sign in to comment.