public AliasStorage::aliasExists($alias, $langcode, $source = NULL)
Checks if alias already exists.
The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.
string $alias: Alias to check against.
string $langcode: Language of the alias.
string|null $source: (optional) Path that alias is to be assigned to.
bool TRUE if alias already exists and FALSE otherwise.
Overrides AliasStorageInterface::aliasExists
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('source', $this->connection->escapeLike($source), 'NOT LIKE'); } $query->addExpression('1'); $query->range(0, 1); try { return (bool) $query->execute()->fetchField(); } catch (\Exception $e) { $this->catchException($e); return FALSE; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Path!AliasStorage.php/function/AliasStorage::aliasExists/8.1.x