class OrderEventsSubscriber in Commerce Demo 8
Hierarchy
- class \Drupal\commerce_demo\EventSubscriber\OrderEventsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of OrderEventsSubscriber
1 string reference to 'OrderEventsSubscriber'
1 service uses OrderEventsSubscriber
File
- src/
EventSubscriber/ OrderEventsSubscriber.php, line 9
Namespace
Drupal\commerce_demo\EventSubscriberView source
class OrderEventsSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[OrderEvents::ORDER_CREATE][] = [
'onOrderCreate',
];
return $events;
}
/**
* Reacts to an order being created..
*
* @param \Drupal\commerce_order\Event\OrderEvent $event
* The order event.
*/
public function onOrderCreate(OrderEvent $event) {
$order = $event
->getOrder();
if ($order
->getCustomer()
->isAnonymous()) {
$order
->setEmail(sprintf('demo+%s@commercekickstart.com', time()));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OrderEventsSubscriber:: |
public static | function | ||
OrderEventsSubscriber:: |
public | function | Reacts to an order being created.. |