function forms_steps_entity_predelete in Forms Steps 8
Implements hook_entity_predelete().
Delete workflow entities when original entity is deleted
File
- ./
forms_steps.module, line 154 - Hook implementations for the forms_steps module.
Code
function forms_steps_entity_predelete($entity) {
if ($entity
->getEntityTypeId() !== 'forms_steps_workflow') {
// Get entity id.
$entity_id = $entity
->id();
// EntityQuery on Workflow entities.
$query = \Drupal::entityQuery(Workflow::ENTITY_TYPE);
$query
->condition('entity_id', $entity_id);
$workflow_entity_ids = $query
->execute();
if ($workflow_entity_ids) {
// Loop through results so we can load the result as an entity to delete.
foreach ($workflow_entity_ids as $workflow_entity_id) {
$workflow_entity = Workflow::load($workflow_entity_id);
$workflow_entity
->delete();
}
}
}
}