function AliasStorage::preloadPathAlias
Pre-loads path alias information for a given list of source paths.
Parameters
array $preloaded: Paths that need preloading of 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[] Source (keys) to alias (values) mapping.
Overrides AliasStorageInterface::preloadPathAlias
File
-
core/
lib/ Drupal/ Core/ Path/ AliasStorage.php, line 199
Class
- AliasStorage
- Provides a class for CRUD operations on path aliases.
Namespace
Drupal\Core\PathCode
public function preloadPathAlias($preloaded, $langcode) {
$select = $this->getBaseQuery()
->fields('base_table', [
'path',
'alias',
]);
if (!empty($preloaded)) {
$conditions = new Condition('OR');
foreach ($preloaded as $preloaded_item) {
$conditions->condition('base_table.path', $this->connection
->escapeLike($preloaded_item), 'LIKE');
}
$select->condition($conditions);
}
$this->addLanguageFallback($select, $langcode);
// We order by ID ASC so that fetchAllKeyed() returns the most recently
// created alias for each source. Subsequent queries using fetchField() must
// use ID DESC to have the same effect.
$select->orderBy('base_table.id', 'ASC');
return $select->execute()
->fetchAllKeyed();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.