Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Connection.php

function Connection::dispatchEvent

Dispatches a database API event via the container dispatcher.

Parameters

\Drupal\Core\Database\Event\DatabaseEvent $event: The database event.

string|null $eventName: (Optional) the name of the event to dispatch.

Return value

\Drupal\Core\Database\Event\DatabaseEvent The database event.

Throws

\Drupal\Core\Database\Exception\EventException If the container is not initialized.

File

core/lib/Drupal/Core/Database/Connection.php, line 1525

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function dispatchEvent(DatabaseEvent $event, ?string $eventName = NULL) : DatabaseEvent {
    if (\Drupal::hasService('event_dispatcher')) {
        return \Drupal::service('event_dispatcher')->dispatch($event, $eventName);
    }
    throw new EventException('The event dispatcher service is not available. Database API events can only be fired if the container is initialized');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal