You are here

protected function OverviewController::getEventLink in MongoDB 8.2

Build the link to the event or top report for the event template.

Parameters

\Drupal\mongodb_watchdog\EventTemplate $template: The event template for which to buildl the link.

Return value

\Drupal\Core\Render\RenderableInterface An internal link in renderable form.

1 call to OverviewController::getEventLink()
OverviewController::buildMainTableRows in modules/mongodb_watchdog/src/Controller/OverviewController.php
Build the main table rows.

File

modules/mongodb_watchdog/src/Controller/OverviewController.php, line 250

Class

OverviewController
The controller for the logger overview page.

Namespace

Drupal\mongodb_watchdog\Controller

Code

protected function getEventLink(EventTemplate $template) : RenderableInterface {
  switch ($template->type) {
    case 'page not found':
      $cell = Link::createFromRoute($this
        ->t('( Top 404 )'), 'mongodb_watchdog.reports.top404');
      break;
    case 'access denied':
      $cell = Link::createFromRoute($this
        ->t('( Top 403 )'), 'mongodb_watchdog.reports.top403');
      break;

    // Limited-length message.
    default:
      $markup = new FormattableMarkup($template->message, []);
      $message = Unicode::truncate(strip_tags($markup
        ->__toString()), 56, TRUE, TRUE);
      $cell = Link::createFromRoute($message, 'mongodb_watchdog.reports.detail', [
        'eventTemplate' => $template->_id,
      ]);
      break;
  }
  return $cell;
}