You are here

public function AliasUniquifier::isRoute in Pathauto 8

Verify if the given path is a valid route.

Parameters

string $path: A string containing a relative path.

Return value

bool TRUE if the path already exists.

Throws

\InvalidArgumentException

1 call to AliasUniquifier::isRoute()
AliasUniquifier::isReserved in src/AliasUniquifier.php
Checks if an alias is reserved.

File

src/AliasUniquifier.php, line 148

Class

AliasUniquifier
Provides a utility for creating a unique path alias.

Namespace

Drupal\pathauto

Code

public function isRoute($path) {
  if (is_file(DRUPAL_ROOT . '/' . $path) || is_dir(DRUPAL_ROOT . '/' . $path)) {

    // Do not allow existing files or directories to get assigned an automatic
    // alias. Note that we do not need to use is_link() to check for symbolic
    // links since this returns TRUE for either is_file() or is_dir() already.
    return TRUE;
  }
  $routes = $this->routeProvider
    ->getRoutesByPattern($path);

  // Only return true for an exact match, ignore placeholders.
  foreach ($routes as $route) {
    if ($route
      ->getPath() == $path) {
      return TRUE;
    }
  }
  return FALSE;
}