You are here

function path_save in Redis 7.2

Same name and namespace in other branches
  1. 7.3 redis.path.inc \path_save()

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.
  • language: (optional) The language of the alias.

File

./redis.path.inc, line 429
Drupal default includes/path.inc file copy which only differs in:

Code

function path_save(&$path) {
  $path += array(
    'language' => 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'])) {
    drupal_write_record('url_alias', $path);
    module_invoke_all('path_insert', $path);
  }
  else {
    drupal_write_record('url_alias', $path, array(
      'pid',
    ));
    module_invoke_all('path_update', $path);
  }
  if (!empty($path['original'])) {
    redis_path_backend_get()
      ->deleteAlias($path['original']['source'], $path['original']['alias'], $path['original']['language']);
  }
  redis_path_backend_get()
    ->saveAlias($path['source'], $path['alias'], $path['language']);

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

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