You are here

public function AcsfEventDispatcher::dispatch in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 src/Event/AcsfEventDispatcher.php \Drupal\acsf\Event\AcsfEventDispatcher::dispatch()

Dispatches a list of event handlers.

Parameters

AcsfEvent $event: The AcsfEvent that is being executed.

File

src/Event/AcsfEventDispatcher.php, line 34

Class

AcsfEventDispatcher
AcsfEventDispatcher.

Namespace

Drupal\acsf\Event

Code

public function dispatch(AcsfEvent $event) {
  $this->running = TRUE;
  while ($this->running && ($handler = $event
    ->popHandler('incomplete'))) {
    try {

      // Capture some information about the handler.
      $handler->started = microtime(TRUE);
      $handler
        ->handle();
      $handler->completed = microtime(TRUE);
      $event
        ->pushHandler($handler, 'complete');
    } catch (\Exception $e) {
      $handler->message = sprintf('Class %s handler failed for event %s: %s', get_class($handler), $event->type, $e
        ->getMessage());
      $event
        ->pushHandler($handler, 'failed');
    }
  }
}