public function PanelizerEntityDefault::hook_field_attach_delete_revision in Panelizer 7.2
Same name and namespace in other branches
- 7.3 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::hook_field_attach_delete_revision()
Overrides PanelizerEntityInterface::hook_field_attach_delete_revision
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 857 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
public function hook_field_attach_delete_revision($entity) {
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
// Locate and delete all displays associated with the entity.
$revisions = db_query("SELECT revision_id, did FROM {panelizer_entity} WHERE entity_type = '{$this->entity_type}' AND entity_id = :id", array(
':id' => $entity_id,
))
->fetchAllAssoc('revision_id');
// It is possible to have the same did on multiple revisions, if none of
// those revisions modified the display. Be careful NOT to delete a display
// that might be in use by another revision.
$seen = array();
foreach ($revisions as $info) {
if ($info->revision_id != $revision_id) {
$seen[$info->did] = TRUE;
}
}
if (!empty($revisions[$revision_id]->did) && empty($seen[$revisions[$revision_id]->did])) {
panels_delete_display($revisions[$revision_id]->did);
}
db_delete('panelizer_entity')
->condition('entity_type', $this->entity_type)
->condition('entity_id', $entity_id)
->condition('revision_id', $revision_id)
->execute();
}