public function Database::save in Audit Log 8
Same name and namespace in other branches
- 8.2 src/StorageBackend/Database.php \Drupal\audit_log\StorageBackend\Database::save()
Writes the event to the storage backend's storage system.
Parameters
\Drupal\audit_log\AuditLogEventInterface $event: The event to be written to the log.
Overrides StorageBackendInterface::save
File
- src/
StorageBackend/ Database.php, line 17
Class
- Database
- Writes audit events to a custom database table.
Namespace
Drupal\audit_log\StorageBackendCode
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();
}