You are here

public function FieldCollection::delete in Field collection 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/FieldCollection.php \Drupal\field_collection\Plugin\Field\FieldType\FieldCollection::delete()

Defines custom delete behavior for field values.

This method is called during the process of deleting an entity, just before values are deleted from storage.

Overrides FieldItemBase::delete

File

src/Plugin/Field/FieldType/FieldCollection.php, line 163

Class

FieldCollection
Plugin implementation of the 'field_collection' field type.

Namespace

Drupal\field_collection\Plugin\Field\FieldType

Code

public function delete() {
  $field_collection_item = $this
    ->getFieldCollectionItem();
  if ($field_collection_item !== NULL) {

    // Set a flag so the field collection item entity knows that the field in
    // its host is already being taken care of.
    // See \Drupal\field_collection\Entity\FieldCollectionItem::delete().
    $field_collection_item->field_collection_deleting = TRUE;
    $field_collection_item
      ->delete();
  }
  parent::delete();
}