public function AliasStorageHelper::loadBySource in Pathauto 8
Fetches an existing URL alias given a path and optional language.
Parameters
string $source: An internal Drupal path.
string $language: An optional language code to look up the path in.
Return value
bool|array FALSE if no alias was found or an associative array containing the following keys:
- source (string): The internal system path with a starting slash.
- alias (string): The URL alias with a starting slash.
- pid (int): Unique path alias identifier.
- langcode (string): The language code of the alias.
Overrides AliasStorageHelperInterface::loadBySource
File
- src/
AliasStorageHelper.php, line 164
Class
- AliasStorageHelper
- Provides helper methods for accessing alias storage.
Namespace
Drupal\pathautoCode
public function loadBySource($source, $language = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$alias = $this->aliasRepository
->lookupBySystemPath($source, $language);
if ($alias) {
return [
'pid' => $alias['id'],
'alias' => $alias['alias'],
'source' => $alias['path'],
'langcode' => $alias['langcode'],
];
}
}