You are here

protected function DbLogController::createLink in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::createLink()
  2. 9 core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::createLink()

Creates a Link object if the provided URI is valid.

Parameters

string|null $uri: The uri string to convert into link if valid.

Return value

\Drupal\Core\Link|string|null Return a Link object if the uri can be converted as a link. In case of empty uri or invalid, fallback to the provided $uri.

1 call to DbLogController::createLink()
DbLogController::eventDetails in core/modules/dblog/src/Controller/DbLogController.php
Displays details about a specific database log message.

File

core/modules/dblog/src/Controller/DbLogController.php, line 395

Class

DbLogController
Returns responses for dblog routes.

Namespace

Drupal\dblog\Controller

Code

protected function createLink($uri) {
  if ($uri !== NULL && UrlHelper::isValid($uri, TRUE)) {
    return new Link($uri, Url::fromUri($uri));
  }
  return $uri;
}