function AliasStorage::pathHasMatchingAlias

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 328

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.