You are here

public static function ContextCreatorTrait::createContextFromOrder in Commerce Stock 8

Creates a commerce context object.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The commerce order obejct.

int|null $time: The unix timestamp, or NULL to use the current time.

array $data: The data.

Return value

\Drupal\commerce\Context The context.

6 calls to ContextCreatorTrait::createContextFromOrder()
OrderEventSubscriber::onOrderCancel in src/EventSubscriber/OrderEventSubscriber.php
Performs a stock transaction for an order Cancel event.
OrderEventSubscriber::onOrderDelete in src/EventSubscriber/OrderEventSubscriber.php
Performs a stock transaction on an order delete event.
OrderEventSubscriber::onOrderItemDelete in src/EventSubscriber/OrderEventSubscriber.php
Performs a stock transaction when an order item is deleted.
OrderEventSubscriber::onOrderItemUpdate in src/EventSubscriber/OrderEventSubscriber.php
Performs a stock transaction on an order item update.
OrderEventSubscriber::onOrderPlace in src/EventSubscriber/OrderEventSubscriber.php
Creates a stock transaction when an order is placed.

... See full list

File

src/ContextCreatorTrait.php, line 108

Class

ContextCreatorTrait
Provides trait to create a commerce context object from a purchasable entity.

Namespace

Drupal\commerce_stock

Code

public static function createContextFromOrder(OrderInterface $order, $time = NULL, array $data = []) {
  return new Context($order
    ->getCustomer(), $order
    ->getStore(), $time, $data);
}