1 path.inc path_load_multiple(array $keys, $field, $langcode)

Load a collection of URL aliases from the database all at once.

Parameters

array $keys: An array of keys by which the aliases should be loaded. This array may contain a list of PIDs, sources, or aliases. The type of content within this array is determined by the $field parameter.

string $field: The type of data used within the $keys array. May be either "pid", "source", or "alias".

string $langcode: The langcode of the paths to be loaded.

Return value

array: An array of the loaded paths, keyed by the $field parameter values.

File

core/includes/path.inc, line 402
Functions to handle paths in Backdrop, including URL aliasing.

Code

function path_load_multiple(array $keys, $field, $langcode) {
  $subquery = db_select('url_alias')
    ->condition($field, $keys, 'IN')
    ->condition('langcode', $langcode)
    ->groupBy($field);
  $subquery->addExpression('MAX(pid)', 'pid');

  $paths = db_select('url_alias')
    ->fields('url_alias')
    ->condition('pid', $subquery, 'IN')
    ->execute()
    ->fetchAllAssoc($field, PDO::FETCH_ASSOC);

  // Cast the auto column to boolean or NULL if unknown.
  foreach ($paths as $key => $path) {
    $paths[$key]['auto'] = is_null($path['auto']) ? NULL : (bool) $path['auto'];
  }

  return $paths;
}