public function AuditLogLogger::log in Audit Log 8
Same name and namespace in other branches
- 8.2 src/AuditLogLogger.php \Drupal\audit_log\AuditLogLogger::log()
Logs an event to the audit log.
Parameters
string $event_type: The type of event being reported such as "insert", "update", or "delete".
\Drupal\Core\Entity\EntityInterface $entity: The entity affected during the event.
File
- src/
AuditLogLogger.php, line 29
Class
- AuditLogLogger
- Service for responding to audit log events.
Namespace
Drupal\audit_logCode
public function log($event_type, EntityInterface $entity) {
$event = new AuditLogEvent();
$account = \Drupal::service('current_user')
->getAccount();
$event
->setUser($account);
$event
->setEntity($entity);
$event
->setEventType($event_type);
$event
->setRequestTime(REQUEST_TIME);
foreach ($this
->sortEventSubscribers() as $event_subscriber) {
if ($event_subscriber
->reactTo($event)) {
\Drupal::service('audit_log.storage')
->save($event);
break;
}
}
}