You are here

private function UserInputParserTrait::resolveUri in Warmer 8

Same name and namespace in other branches
  1. 2.x modules/warmer_cdn/src/Plugin/warmer/UserInputParserTrait.php \Drupal\warmer_cdn\Plugin\warmer\UserInputParserTrait::resolveUri()

Resolves a URI into a fully loaded URL.

Parameters

string $user_input: The user input for the URL. Examples: internal://<front>, entity://user/1, /node/2, https://example.org.

Return value

string The fully loaded URL.

File

modules/warmer_cdn/src/Plugin/warmer/UserInputParserTrait.php, line 66

Class

UserInputParserTrait
Common methods to parse user input.

Namespace

Drupal\warmer_cdn\Plugin\warmer

Code

private function resolveUri($user_input) {
  try {
    return Url::fromUri($user_input, [
      'absolute' => TRUE,
    ])
      ->toString();
  } catch (\InvalidArgumentException $e) {
  }
  try {
    return Url::fromUserInput($user_input, [
      'absolute' => TRUE,
    ])
      ->toString();
  } catch (\InvalidArgumentException $e) {
  }
  return $user_input;
}