class AuditLogStorage in Audit Log 8
Same name and namespace in other branches
- 8.2 src/AuditLogStorage.php \Drupal\audit_log\AuditLogStorage
Writes audit log events to enabled logging destinations.
@package Drupal\audit_log
Hierarchy
- class \Drupal\audit_log\AuditLogStorage
Expanded class hierarchy of AuditLogStorage
1 string reference to 'AuditLogStorage'
1 service uses AuditLogStorage
File
- src/
AuditLogStorage.php, line 12
Namespace
Drupal\audit_logView source
class AuditLogStorage {
/**
* An array of available log destinations to be written to.
*
* @var array
*/
protected $storage_backends;
/**
* Writes the audit event to each available logging destination.
*
* @param \Drupal\audit_log\AuditLogEventInterface $event
* The audit event to be logged.
*/
public function save(AuditLogEventInterface $event) {
foreach ($this
->sortStorageBackends() as $storage_backend) {
$storage_backend
->save($event);
}
}
/**
* Adds a log destination to the processing pipeline.
*
* @param \Drupal\audit_log\StorageBackend\StorageBackendInterface $storage_backend
* The logging destination to write events to.
* @param int $priority
* A priority specification for the storage backend s.
*
* Must be a positive integer.
*
* Lower number storage backend s are processed
* before higher number storage backend s.
*/
public function addStorageBackend(StorageBackendInterface $storage_backend, $priority = 0) {
$this->storage_backends[$priority][] = $storage_backend;
}
/**
* Sorts the available logging destinations by priority.
*
* @return array
* The sorted array of logging destinations.
*/
protected function sortStorageBackends() {
$sorted = [];
krsort($this->storage_backends);
foreach ($this->storage_backends as $storage_backends) {
$sorted = array_merge($sorted, $storage_backends);
}
return $sorted;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuditLogStorage:: |
protected | property | An array of available log destinations to be written to. | |
AuditLogStorage:: |
public | function | Adds a log destination to the processing pipeline. | |
AuditLogStorage:: |
public | function | Writes the audit event to each available logging destination. | |
AuditLogStorage:: |
protected | function | Sorts the available logging destinations by priority. |