function path_node_insert

7.x path.module path_node_insert($node)

Implements hook_node_insert().

1 call to path_node_insert()
path_node_update in drupal-7.x/modules/path/path.module
Implements hook_node_update().

File

drupal-7.x/modules/path/path.module, line 187
Enables users to rename URLs.

Code

function path_node_insert($node) {
  if (isset($node->path)) {
    $path = $node->path;
    $path['alias'] = trim($path['alias']);
    // Only save a non-empty alias.
    if (!empty($path['alias'])) {
      // Ensure fields for programmatic executions.
      $langcode = entity_language('node', $node);
      $path['source'] = 'node/' . $node->nid;
      $path['language'] = isset($langcode) ? $langcode : LANGUAGE_NONE;
      path_save($path);
    }
  }
}