You are here

public function AliasStorage::lookupPathSource in Drupal 8

Returns Drupal system URL of an alias.

The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.

Parameters

string $path: The path to investigate for corresponding system URLs.

string $langcode: Language code to search the path with. If there's no path defined for that language it will search paths without language.

Return value

string|false A Drupal system path, or FALSE if no path was found.

Overrides AliasStorageInterface::lookupPathSource

File

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

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

public function lookupPathSource($alias, $langcode) {

  // See the queries above. Use LIKE for case-insensitive matching.
  $select = $this
    ->getBaseQuery()
    ->fields('base_table', [
    'path',
  ])
    ->condition('base_table.alias', $this->connection
    ->escapeLike($alias), 'LIKE');
  $this
    ->addLanguageFallback($select, $langcode);
  $select
    ->orderBy('base_table.id', 'DESC');
  return $select
    ->execute()
    ->fetchField();
}