function PanelizerEntityDefault::delete_entity_panelizer in Panelizer 7.3
Same name and namespace in other branches
- 7.2 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::delete_entity_panelizer()
Delete panelizers associated with the entity.
Parameters
object $entity: The entity.
string $view_mode: The view mode to delete. If not specified, all view modes will be deleted.
bool $one_revision: Whether to delete all revisions for this entity, or a specific one.
2 calls to PanelizerEntityDefault::delete_entity_panelizer()
- PanelizerEntityDefault::hook_entity_delete in plugins/
entity/ PanelizerEntityDefault.class.php - PanelizerEntityDefault::hook_entity_update in plugins/
entity/ PanelizerEntityDefault.class.php
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 2600 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
function delete_entity_panelizer($entity, $view_mode = NULL, $one_revision = FALSE) {
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
// Locate any displays associated with the entity.
$query = db_select('panelizer_entity', 'pe')
->fields('pe', array(
'did',
))
->condition('entity_type', $this->entity_type)
->condition('entity_id', $entity_id);
if (!empty($view_mode)) {
$query
->condition('view_mode', $view_mode);
}
if (!empty($revision_id) && !empty($one_revision)) {
$query
->condition('revision_id', $revision_id);
}
$dids = $query
->execute()
->fetchCol();
// Delete the Panels displays.
foreach (array_unique(array_filter($dids)) as $did) {
panels_delete_display($did);
}
// Delete the {panelizer_entity} records.
$delete = db_delete('panelizer_entity')
->condition('entity_type', $this->entity_type)
->condition('entity_id', $entity_id);
if (!empty($view_mode)) {
$delete
->condition('view_mode', $view_mode);
}
if (!empty($revision_id) && !empty($one_revision)) {
$delete
->condition('revision_id', $revision_id);
}
$delete
->execute();
// Reset the entity's cache. If the EntityCache module is enabled, this also
// resets its permanent cache.
entity_get_controller($this->entity_type)
->resetCache(array(
$entity_id,
));
}