Closed (works as designed)
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Entity property wrapper
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Aug 2011 at 18:09 UTC
Updated:
16 Dec 2011 at 21:57 UTC
/**
* Implements hook_entity_delete().
*
* Delete group membership of deleted entity.
*/
function og_entity_delete($entity, $type) {
$wrapper = entity_metadata_wrapper($type, $entity);
if (!isset($wrapper->og_membership)) {
return;
}
foreach ($wrapper->og_membership->value() as $og_membership) {
$og_membership->delete();
}
}
In the above code OgMemerbship::delete() is called.
If I change the line to be foreach ($wrapper->og_membership as $og_membership) {
where $og_membership is a wrapper, Entity::delete() is called instead of OgMemerbship::delete().
Comments
Comment #1
fagoyou mean entity_delete_multiple() I guess.
Deletion always goes through the controller, but not through Entity:delete(), because of multiple deletion. Thus, for modifying delete behaviour you have to override the controller.
Comment #2
amitaibuI do override the delete, that's why $og_membership->delete() works ok; but $wrapper->delete() for some reason doesn't -- or am I missing your point ;)
Comment #3
amitaibu> but $wrapper->delete() for some reason doesn't -- or am I missing your point ;)
Ok, I've seen what it's doing -- it calls the controller class not the entity class. Took me some time to get back to this issue ;)