protected function LogsHttpLogger::addEventToCache in Logs HTTP 8
Add an event to static cache.
Prevent adding the same event, occurred in the same request, twice.
Parameters
array $event: The event to register in the static cache.
Return value
bool TRUE if added to cache, otherwise FALSE, indicating is was already added previously.
1 call to LogsHttpLogger::addEventToCache()
- LogsHttpLogger::log in src/
Logger/ LogsHttpLogger.php
File
- src/
Logger/ LogsHttpLogger.php, line 135
Class
- LogsHttpLogger
- Implements a Logs Http Logger instance.
Namespace
Drupal\logs_http\LoggerCode
protected function addEventToCache(array $event) {
// Remove empty values, to prevent errors in the indexing of the JSON.
$event = $this
->arrayRemoveEmpty($event);
// Prevent identical events.
$event_clone = $event;
unset($event_clone['timestamp']);
$key = md5(serialize($event_clone));
$is_unique = !empty($this->cache[$key]);
$this->cache[$key] = $event;
return $is_unique;
}