class Database in Audit Log 8
Same name and namespace in other branches
- 8.2 src/StorageBackend/Database.php \Drupal\audit_log\StorageBackend\Database
Writes audit events to a custom database table.
@package Drupal\audit_log\StorageBackend
Hierarchy
- class \Drupal\audit_log\StorageBackend\Database implements StorageBackendInterface
Expanded class hierarchy of Database
1 string reference to 'Database'
1 service uses Database
File
- src/
StorageBackend/ Database.php, line 12
Namespace
Drupal\audit_log\StorageBackendView source
class Database implements StorageBackendInterface {
/**
* {@inheritdoc}
*/
public function save(AuditLogEventInterface $event) {
$connection = \Drupal::database();
$connection
->insert('audit_log')
->fields([
'entity_id' => $event
->getEntity()
->id(),
'entity_type' => $event
->getEntity()
->getEntityTypeId(),
'user_id' => $event
->getUser()
->id(),
'event' => $event
->getEventType(),
'previous_state' => $event
->getPreviousState(),
'current_state' => $event
->getCurrentState(),
'message' => $event
->getMessage(),
'variables' => serialize($event
->getMessagePlaceholders()),
'timestamp' => $event
->getRequestTime(),
])
->execute();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Database:: |
public | function |
Writes the event to the storage backend's storage system. Overrides StorageBackendInterface:: |