delete.action.inc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @file
  4. * Implements a generic entity delete action. Uses Entity API if available.
  5. */
  6. function views_bulk_operations_delete_action_info() {
  7. return array(
  8. 'views_bulk_operations_delete_item' => array(
  9. 'type' => 'entity',
  10. 'label' => t('Delete item'),
  11. 'configurable' => FALSE,
  12. 'behavior' => array('deletes_property'),
  13. 'triggers' => array('any'),
  14. ),
  15. 'views_bulk_operations_delete_revision' => array(
  16. 'type' => 'entity',
  17. 'label' => t('Delete revision'),
  18. 'configurable' => FALSE,
  19. 'behavior' => array('deletes_property'),
  20. 'triggers' => array('any'),
  21. ),
  22. );
  23. }
  24. function views_bulk_operations_delete_item($entity, $context) {
  25. $info = entity_get_info($context['entity_type']);
  26. $entity_id = $entity->{$info['entity keys']['id']};
  27. entity_delete($context['entity_type'], $entity_id);
  28. }
  29. function views_bulk_operations_delete_revision($entity, $context) {
  30. $info = entity_get_info($context['entity_type']);
  31. $revision_id = $entity->{$info['entity keys']['revision']};
  32. entity_revision_delete($context['entity_type'], $revision_id);
  33. }