function DbLogController::createLink

Same name in other branches
  1. 8.9.x core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::createLink()
  2. 10 core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::createLink()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.