function path_save

You are here

7 path.inc path_save(&$path)
4.6 path.module path_save($edit)

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.
9 calls to path_save()
LocalePathFunctionalTest::testPathLanguageConfiguration in modules/locale/locale.test
Test if a language can be associated with a path alias.
PathLookupTest::testDrupalLookupPath in modules/simpletest/tests/path.test
Test that drupal_lookup_path() returns the correct path.
PathSaveTest::testDrupalSaveOriginalPath in modules/simpletest/tests/path.test
Tests that path_save() makes the original path available to modules.
path_admin_form_submit in modules/path/path.admin.inc
Form submission handler for path_admin_form().
path_node_insert in modules/path/path.module
Implements hook_node_insert().

... See full list

File

includes/path.inc, line 433
Functions to handle paths in Drupal, including path aliasing.

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);
  }

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

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

Comments

In prior versions of Drupal (6 and before), this function (or something similar) was called path_set_alias()
http://api.drupal.org/api/drupal/modules--path--path.module/function/pat...