1 path.inc path_save(&$path)

Save a path alias to the database.

Parameters

$path: An associative array containing the following keys:

  • source: The internal system path.
  • alias: The URL alias.
  • pid: (optional) Unique path alias identifier.
  • langcode: (optional) The language code of the alias.

File

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

Code

function path_save(&$path) {
  $path += array('langcode' => LANGUAGE_NONE);

  // Load the stored alias, if any.
  if (!empty($path['pid']) && !isset($path['original'])) {
    $path['original'] = path_load($path['pid']);
  }

  if (empty($path['pid'])) {
    backdrop_write_record('url_alias', $path);
    module_invoke_all('path_insert', $path);
  }
  else {
    backdrop_write_record('url_alias', $path, array('pid'));
    module_invoke_all('path_update', $path);
  }

  // Clear internal properties.
  unset($path['original']);

  // Clear the static alias cache.
  backdrop_clear_path_cache($path['source']);
}