protected function CoreStockEventsBase::getMetadata in Commerce Stock 8
Helper method for building the transaction metadata.
Parameters
\Drupal\commerce_order\Entity\Order $order: The commerce order.
\Drupal\commerce_stock\Plugin\Commerce\StockEventType\StockEventTypeInterface $stock_event_type: The stock event type.
string|null $message: An optional transaction message.
array $data: Arbitrary data to save in transactions metadata.
Return value
array The metadata.
File
- src/
Plugin/ StockEvents/ CoreStockEventsBase.php, line 30
Class
- CoreStockEventsBase
- Core stock events base class.
Namespace
Drupal\commerce_stock\Plugin\StockEventsCode
protected function getMetadata(Order $order, StockEventTypeInterface $stock_event_type, $message = NULL, array $data = []) {
$metadata = array_merge([
'message' => $message ?: $stock_event_type
->getDefaultMessage(),
], $data);
return [
'related_oid' => $order
->id(),
'related_uid' => $order
->getCustomerId(),
'data' => $metadata,
];
}