public function EntityPredelete::entityDelete in Entity Reference Integrity 8
Implements hook_entity_delete().
File
- modules/
entity_reference_integrity_enforce/ src/ EntityPredelete.php, line 51
Class
- EntityPredelete
- Hook into entity deletes and throw an exception to prevent them disappearing.
Namespace
Drupal\entity_reference_integrity_enforceCode
public function entityDelete(EntityInterface $entity) {
if (in_array($entity
->getEntityTypeId(), $this->enabledEntityTypeIds, TRUE) && $this->dependencyManager
->hasDependents($entity)) {
throw new ProtectedEntityException(sprintf('Cannot delete "%s" of type "%s" with label "%s" and ID "%s" because other content is referencing it and the integrity of this entity type is enforced.', $entity
->getEntityTypeId(), $entity
->bundle(), $entity
->label(), $entity
->id()));
}
}