protected function OverviewController::getEventSource in MongoDB 8.2
Get the location in source code where the event was logged.
Parameters
\Drupal\mongodb_watchdog\EventTemplate $template: The template for which to find a source location.
Return value
array A render array for the source location, possibly empty or wrong.
1 call to OverviewController::getEventSource()
- OverviewController::buildMainTableRows in modules/
mongodb_watchdog/ src/ Controller/ OverviewController.php - Build the main table rows.
File
- modules/
mongodb_watchdog/ src/ Controller/ OverviewController.php, line 283
Class
- OverviewController
- The controller for the logger overview page.
Namespace
Drupal\mongodb_watchdog\ControllerCode
protected function getEventSource(EventTemplate $template) : array {
$cell = [
'#markup' => '',
];
if (in_array($template->type, TopController::TYPES)) {
return $cell;
}
$eventCollection = $this->watchdog
->eventCollection($template->_id);
$event = $eventCollection
->findOne([], static::EVENT_TYPE_MAP);
if (!$event instanceof Event) {
return $cell;
}
$file = $event->variables['%file'] ?? '';
if ($file && strncmp($file, DRUPAL_ROOT, $this->rootLength) === 0) {
$hover = mb_substr($file, $this->rootLength + 1);
$file = Unicode::truncate(basename($file), 30);
}
else {
$hover = '';
}
$line = $event->variables['%line'] ?? '';
$cell = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => implode("#", [
$file,
$line,
]),
];
if ($hover !== '') {
$cell['#attributes'] = [
'class' => 'mongodb-watchdog__code-path',
'title' => $hover,
];
}
return $cell;
}