function EntityOperations::entityDelete

Implements hook_entity_delete().

Attributes

#[Hook('entity_delete')]

File

core/modules/workspaces/src/Hook/EntityOperations.php, line 133

Class

EntityOperations
Defines a class for reacting to entity runtime hooks.

Namespace

Drupal\workspaces\Hook

Code

public function entityDelete(EntityInterface $entity) : void {
  if (!$this->workspaceInfo
    ->isEntityTypeSupported($entity->getEntityType())) {
    return;
  }
  $this->workspaceAssociation
    ->deleteAssociations(NULL, $entity->getEntityTypeId(), [
    $entity->id(),
  ]);
  $this->workspaceManager
    ->getActiveWorkspace()?->getProvider()
    ->entityDelete($entity);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.