You are here

public static function EmailSubscriber::getSubscribedEvents in Commerce Email 8

File

src/EventSubscriber/EmailSubscriber.php, line 38

Class

EmailSubscriber
Subscribes to Symfony events and maps them to email events.

Namespace

Drupal\commerce_email\EventSubscriber

Code

public static function getSubscribedEvents() {

  // This method could be called early when the container is built, so the
  // email event manager might not be available yet.
  if (!\Drupal::hasService('plugin.manager.commerce_email_event')) {
    return [];
  }

  /** @var \Drupal\Core\Plugin\DefaultPluginManager $email_event_manager */
  $email_event_manager = \Drupal::service('plugin.manager.commerce_email_event');
  $email_events = $email_event_manager
    ->getDefinitions();
  $events = [];
  foreach ($email_events as $definition) {
    $events[$definition['event_name']][] = [
      'onEvent',
    ];
  }
  return $events;
}