function AliasStorage::load
Overrides AliasStorageInterface::load
File
-
core/
lib/ Drupal/ Core/ Path/ AliasStorage.php, line 124
Class
- AliasStorage
- Provides a class for CRUD operations on path aliases.
Namespace
Drupal\Core\PathCode
public function load($conditions) {
$query = $this->getPathAliasEntityStorage()
->getQuery();
// Ignore access restrictions for this API.
$query->accessCheck(FALSE);
foreach ($conditions as $field => $value) {
if ($field === 'source') {
$field = 'path';
}
elseif ($field === 'pid') {
$field = 'id';
}
$query->condition($field, $value, '=');
}
$result = $query->sort('id', 'DESC')
->range(0, 1)
->execute();
$entities = $this->getPathAliasEntityStorage()
->loadMultiple($result);
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
$path_alias = reset($entities);
if ($path_alias) {
return [
'pid' => $path_alias->id(),
'source' => $path_alias->getPath(),
'alias' => $path_alias->getAlias(),
'langcode' => $path_alias->get('langcode')->value,
];
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.