public function GroupController::savePath in Group 7
Updates a group path alias upon saving.
Parameters
Group $group: The group being saved.
1 call to GroupController::savePath()
- GroupController::save in classes/
group.controller.inc - Save a group.
File
- classes/
group.controller.inc, line 178 - Defines the Entity API CRUD class for groups.
Class
- GroupController
- Controller for group entities.
Code
public function savePath(Group $group) {
if (isset($group->path)) {
$path = $group->path;
$path['alias'] = trim($path['alias']);
// Delete old alias if user erased it.
if (empty($group->is_new)) {
if (!empty($path['pid']) && empty($path['alias'])) {
path_delete($path['pid']);
}
}
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$langcode = entity_language('group', $group);
$path['source'] = 'group/' . $group->gid;
$path['language'] = isset($langcode) ? $langcode : LANGUAGE_NONE;
path_save($path);
}
}
}