You are here

public function LanguageNeutralAliasesStorage::pathHasMatchingAlias in Language neutral aliases 8

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 AliasStorage::pathHasMatchingAlias

File

src/LanguageNeutralAliasesStorage.php, line 135

Class

LanguageNeutralAliasesStorage
Language neutral alias storage.

Namespace

Drupal\language_neutral_aliases

Code

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