You are here

public function PanelsPaneController::delete in Fieldable Panels Panes (FPP) 7

Delete a list of FPPs.

Parameters

array $fpids: A list of FPP primary keys.

File

includes/PanelsPaneController.class.php, line 373
Contains the controller class for the Fieldable Panel Pane entity.

Class

PanelsPaneController
Entity controller class.

Code

public function delete(array $fpids) {
  $transaction = db_transaction();
  if (!empty($fpids)) {
    $entities = fieldable_panels_panes_load_multiple($fpids, array());
    if (!empty($entities)) {
      try {
        foreach ($entities as $fpid => $entity) {

          // Trigger hook_fieldable_panels_pane_delete().
          module_invoke_all('fieldable_panels_pane_delete', $entity);

          // Trigger hook_entity_delete().
          module_invoke_all('entity_delete', $entity, 'fieldable_panels_pane');
          field_attach_delete('fieldable_panels_pane', $entity);
        }

        // Delete after calling hooks so that they can query entity tables as
        // needed.
        db_delete('fieldable_panels_panes')
          ->condition('fpid', $fpids, 'IN')
          ->execute();
        db_delete('fieldable_panels_panes_revision')
          ->condition('fpid', $fpids, 'IN')
          ->execute();
      } catch (Exception $e) {
        $transaction
          ->rollback();
        watchdog_exception('fieldable_panels_pane', $e);
        throw $e;
      }
    }

    // Clear the page and block and entity_load_multiple caches.
    entity_get_controller('fieldable_panels_pane')
      ->resetCache();
  }
}