function AliasStorage::aliasExists

Overrides AliasStorageInterface::aliasExists

File

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

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

public function aliasExists($alias, $langcode, $source = NULL) {
    // Use LIKE and NOT LIKE for case-insensitive matching.
    $query = $this->connection
        ->select(static::TABLE)
        ->condition('alias', $this->connection
        ->escapeLike($alias), 'LIKE')
        ->condition('langcode', $langcode);
    if (!empty($source)) {
        $query->condition('path', $this->connection
            ->escapeLike($source), 'NOT LIKE');
    }
    $query->addExpression('1');
    $query->range(0, 1);
    return (bool) $query->execute()
        ->fetchField();
}

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