class OrderAssignment in Commerce Core 8.2
Hierarchy
- class \Drupal\commerce_order\OrderAssignment implements OrderAssignmentInterface
Expanded class hierarchy of OrderAssignment
1 string reference to 'OrderAssignment'
- commerce_order.services.yml in modules/
order/ commerce_order.services.yml - modules/order/commerce_order.services.yml
1 service uses OrderAssignment
File
- modules/
order/ src/ OrderAssignment.php, line 12
Namespace
Drupal\commerce_orderView source
class OrderAssignment implements OrderAssignmentInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The event dispatcher.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* Constructs a new OrderAssignment object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, EventDispatcherInterface $event_dispatcher) {
$this->entityTypeManager = $entity_type_manager;
$this->eventDispatcher = $event_dispatcher;
}
/**
* {@inheritdoc}
*/
public function assign(OrderInterface $order, UserInterface $customer, $save_order = TRUE) {
// Notify other modules before the order is modified, so that
// subscribers have access to the original data.
$event = new OrderAssignEvent($order, $customer);
$this->eventDispatcher
->dispatch(OrderEvents::ORDER_ASSIGN, $event);
$order
->setCustomer($customer);
$order
->setEmail($customer
->getEmail());
if ($save_order) {
$order
->save();
}
}
/**
* {@inheritdoc}
*/
public function assignMultiple(array $orders, UserInterface $customer) {
foreach ($orders as $order) {
$this
->assign($order, $customer);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OrderAssignment:: |
protected | property | The entity type manager. | |
OrderAssignment:: |
protected | property | The event dispatcher. | |
OrderAssignment:: |
public | function |
Assigns the order to the given customer. Overrides OrderAssignmentInterface:: |
|
OrderAssignment:: |
public | function |
Assigns multiple orders to the given customer. Overrides OrderAssignmentInterface:: |
|
OrderAssignment:: |
public | function | Constructs a new OrderAssignment object. |