public function AliasRepository::lookupBySystemPath in Drupal 8
Searches a path alias for a given Drupal system path.
The default implementation performs case-insensitive matching on the 'path' and 'alias' strings.
Parameters
string $path: The system path to investigate for corresponding path aliases.
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
array|null An array containing the 'id', 'path', 'alias' and 'langcode' properties of a path alias, or NULL if none was found.
Overrides AliasRepositoryInterface::lookupBySystemPath
File
- core/
lib/ Drupal/ Core/ Path/ AliasRepository.php, line 72
Class
- AliasRepository
- Provides the default path alias lookup operations.
Namespace
Drupal\Core\PathCode
public function lookupBySystemPath($path, $langcode) {
// See the queries above. Use LIKE for case-insensitive matching.
$select = $this
->getBaseQuery()
->fields('base_table', [
'id',
'path',
'alias',
'langcode',
])
->condition('base_table.path', $this->connection
->escapeLike($path), 'LIKE');
$this
->addLanguageFallback($select, $langcode);
$select
->orderBy('base_table.id', 'DESC');
return $select
->execute()
->fetchAssoc() ?: NULL;
}