You are here

public function AliasRepository::pathHasMatchingAlias in Drupal 8

Check if any alias exists starting with $initial_substring.

Parameters

string $initial_substring: Initial system path substring to test against.

Return value

bool TRUE if any alias exists, FALSE otherwise.

Overrides AliasRepositoryInterface::pathHasMatchingAlias

File

core/lib/Drupal/Core/Path/AliasRepository.php, line 104

Class

AliasRepository
Provides the default path alias lookup operations.

Namespace

Drupal\Core\Path

Code

public function pathHasMatchingAlias($initial_substring) {
  $query = $this
    ->getBaseQuery();
  $query
    ->addExpression(1);
  return (bool) $query
    ->condition('base_table.path', $this->connection
    ->escapeLike($initial_substring) . '%', 'LIKE')
    ->range(0, 1)
    ->execute()
    ->fetchField();
}