You are here

public function EntityReferenceRevisionsItem::delete in Entity Reference Revisions 8

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/EntityReferenceRevisionsItem.php, line 407

Class

EntityReferenceRevisionsItem
Defines the 'entity_reference_revisions' entity field type.

Namespace

Drupal\entity_reference_revisions\Plugin\Field\FieldType

Code

public function delete() {
  parent::delete();
  if ($this->entity && $this->entity
    ->getEntityType()
    ->get('entity_revision_parent_type_field') && $this->entity
    ->getEntityType()
    ->get('entity_revision_parent_id_field')) {

    // Only delete composite entities if the host field is not translatable.
    if (!$this
      ->getFieldDefinition()
      ->isTranslatable()) {
      \Drupal::queue('entity_reference_revisions_orphan_purger')
        ->createItem([
        'entity_id' => $this->entity
          ->id(),
        'entity_type_id' => $this->entity
          ->getEntityTypeId(),
      ]);
    }
  }
}