public AliasStorage::lookupPathAlias($path, $langcode)
Returns an alias of Drupal system URL.
The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.
Parameters
string $path: The 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
string|false A path alias, or FALSE if no path was found.
Overrides AliasStorageInterface::lookupPathAlias
File
- core/lib/Drupal/Core/Path/AliasStorage.php, line 228
Class
- AliasStorage
- Provides a class for CRUD operations on path aliases.
Namespace
Drupal\Core\Path
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public function lookupPathAlias( $path , $langcode ) { $source = $this ->connection->escapeLike( $path ); $langcode_list = [ $langcode , LanguageInterface::LANGCODE_NOT_SPECIFIED]; // See the queries above. Use LIKE for case-insensitive matching. $select = $this ->connection->select( static ::TABLE) ->fields( static ::TABLE, [ 'alias' ]) ->condition( 'source' , $source , 'LIKE' ); if ( $langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { array_pop ( $langcode_list ); } elseif ( $langcode > LanguageInterface::LANGCODE_NOT_SPECIFIED) { $select ->orderBy( 'langcode' , 'DESC' ); } else { $select ->orderBy( 'langcode' , 'ASC' ); } $select ->orderBy( 'pid' , 'DESC' ); $select ->condition( 'langcode' , $langcode_list , 'IN' ); try { return $select ->execute()->fetchField(); } catch (\Exception $e ) { $this ->catchException( $e ); return FALSE; } } |
Please login to continue.