You are here

function group_pathauto_update_alias in Group 7

Creates or updates entity alias.

Parameters

Group $group: The group the alias is being created/updated for.

string $op: Operation being performed on the alias ('insert', 'update' or 'bulkupdate').

array $language: Additional parameter to set the language of the path.

Return value

string The alias that was created.

2 calls to group_pathauto_update_alias()
GroupController::save in classes/group.controller.inc
Save a group.
group_pathauto_update_alias_multiple in ./group.pathauto.inc
Update the URL aliases for multiple groups.

File

./group.pathauto.inc, line 140
Hook implementations for the Pathauto module.

Code

function group_pathauto_update_alias(Group $group, $op, $language = NULL) {

  // Skip processing if the user has disabled pathauto for the group.
  if (isset($group->path['pathauto']) && empty($group->path['pathauto'])) {
    return;
  }

  // Make sure the language is set.
  if (!isset($language)) {
    $language = entity_language('group', $group);

    // To preserve some backwards compatibility, entity_language() returns NULL
    // instead of LANGUAGE_NONE when no language is found. Pathauto expects
    // LANGUAGE_NONE, though, so we convert it.
    if (!isset($language)) {
      $language = LANGUAGE_NONE;
    }
  }

  // Skip processing if the entity has no pattern.
  if (!pathauto_pattern_load_by_entity('group', $group->type, $language)) {
    return;
  }
  module_load_include('inc', 'pathauto');
  $uri = entity_uri('group', $group);
  return pathauto_create_alias('group', $op, $uri['path'], array(
    'group' => $group,
  ), $group->type, $language);
}