class StatementExecutionSubscriber
Same name in other branches
- 10 core/lib/Drupal/Core/Database/EventSubscriber/StatementExecutionSubscriber.php \Drupal\Core\Database\EventSubscriber\StatementExecutionSubscriber
Response subscriber to statement executions.
Hierarchy
- class \Drupal\Core\Database\EventSubscriber\StatementExecutionSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of StatementExecutionSubscriber
File
-
core/
lib/ Drupal/ Core/ Database/ EventSubscriber/ StatementExecutionSubscriber.php, line 12
Namespace
Drupal\Core\Database\EventSubscriberView source
class StatementExecutionSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
return [
StatementExecutionEndEvent::class => 'onStatementExecutionEnd',
];
}
/**
* Subscribes to a statement execution finished event.
*
* Logs the statement query if logging is active.
*
* @param \Drupal\Core\Database\Event\StatementExecutionEndEvent $event
* The database event.
*/
public function onStatementExecutionEnd(StatementExecutionEndEvent $event) : void {
$logger = Database::getConnection($event->target, $event->key)
->getLogger();
if ($logger) {
$logger->logFromEvent($event);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
StatementExecutionSubscriber::getSubscribedEvents | public static | function | |
StatementExecutionSubscriber::onStatementExecutionEnd | public | function | Subscribes to a statement execution finished event. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.