public function Group::removeEntity in Group 7
Remove an entity from a group.
You could also manipulate the 'group' property on the entity you wish to remove. Upon saving that entity, it will automatically be removed from the group.
Parameters
int $entity_id: The id of the entity.
string $entity_type: The type of the entity.
1 call to Group::removeEntity()
- Group::removeSubgroup in classes/
group.inc - Remove a subgroup from a group.
File
- classes/
group.inc, line 104 - Defines the Entity API class for groups.
Class
- Group
- Main class for groups.
Code
public function removeEntity($entity_id, $entity_type) {
$query = db_delete('group_entity');
$query
->condition('gid', $this->gid);
$query
->condition('entity_id', $entity_id);
$query
->condition('entity_type', $entity_type);
$query
->execute();
// Remove the entity from its controller's internal cache. This way it will
// have to be loaded again next time it's requested and will thus receive
// an updated 'group' property.
entity_get_controller($entity_type)
->resetCache(array(
$entity_id,
));
// Reset the internal cache.
$this
->resetCache();
}