public function AliasStorage::pathHasMatchingAlias

public AliasStorage::pathHasMatchingAlias($initial_substring)

Check if any alias exists starting with $initial_substring.

Parameters

string $initial_substring: Initial path substring to test against.

Return value

bool TRUE if any alias exists, FALSE otherwise.

Overrides AliasStorageInterface::pathHasMatchingAlias

File

core/lib/Drupal/Core/Path/AliasStorage.php, line 352

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

public function pathHasMatchingAlias($initial_substring) {
  $query = $this->connection->select(static::TABLE, 'u');
  $query->addExpression(1);
  try {
    return (bool) $query
    ->condition('u.source', $this->connection->escapeLike($initial_substring) . '%', 'LIKE')
      ->range(0, 1)
      ->execute()
      ->fetchField();
  }
  catch (\Exception $e) {
    $this->catchException($e);
    return FALSE;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Path!AliasStorage.php/function/AliasStorage::pathHasMatchingAlias/8.1.x