You are here

function paragraphs_field_delete_revision in Paragraphs 7

Implements hook_field_delete_revision().

File

./paragraphs.module, line 833
Paragraphs hooks and common functions.

Code

function paragraphs_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['type'] == 'paragraphs') {
    foreach ($items as $item) {
      if (!empty($item['revision_id'])) {
        if ($paragraphs_item = paragraphs_item_revision_load($item['revision_id'])) {
          $paragraphs_item
            ->setHostEntity($entity_type, $entity, $langcode, FALSE);
          $paragraphs_item
            ->deleteRevision(TRUE);
        }
      }
    }
  }
}