public function AliasStorage::aliasExists in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Path/AliasStorage.php \Drupal\Core\Path\AliasStorage::aliasExists()
Checks if alias already exists.
The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.
Parameters
string $alias: Alias to check against.
string $langcode: Language of the alias.
string|null $source: (optional) Path that alias is to be assigned to.
Return value
bool TRUE if alias already exists and FALSE otherwise.
Overrides AliasStorageInterface::aliasExists
File
- core/
lib/ Drupal/ Core/ Path/ AliasStorage.php, line 236 - Contains \Drupal\Core\Path\AliasStorage.
Class
- AliasStorage
- Provides a class for CRUD operations on path aliases.
Namespace
Drupal\Core\PathCode
public function aliasExists($alias, $langcode, $source = NULL) {
// Use LIKE and NOT LIKE for case-insensitive matching.
$query = $this->connection
->select('url_alias')
->condition('alias', $this->connection
->escapeLike($alias), 'LIKE')
->condition('langcode', $langcode);
if (!empty($source)) {
$query
->condition('source', $this->connection
->escapeLike($source), 'NOT LIKE');
}
$query
->addExpression('1');
$query
->range(0, 1);
return (bool) $query
->execute()
->fetchField();
}