You are here

protected function URL::routeExists in Drupal 7 to 8/9 Module Upgrader 8

Looks up routes by path, and returns TRUE if at least one was found.

Parameters

string $path: The path to search for, not including the leading slash. Can be an external URL.

Return value

bool TRUE if the path matches a route, FALSE otherwise. External URLs will always return FALSE.

1 call to URL::routeExists()
URL::rewrite in src/Plugin/DMU/Converter/Functions/URL.php
Tries to rewrite the original function call.

File

src/Plugin/DMU/Converter/Functions/URL.php, line 45

Class

URL
Plugin annotation @Converter( id = "url", description = @Translation("Rewrites calls to url()."), fixme = @Translation("url() expects a route name or an external URI."), dependencies = { "router.route_provider" } )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions

Code

protected function routeExists($path) {

  // If there's a scheme in the URL, consider this an external URL and don't even
  // try to rewrite it.
  $scheme = parse_url($path, PHP_URL_SCHEME);
  if (isset($scheme)) {
    return FALSE;
  }
  else {
    $routes = $this->routeProvider
      ->getRoutesByPattern('/' . $path);
    return sizeof($routes) > 0;
  }
}