I am looking for the best way to delete children of my main entity when i delete it.
I have 2 entity type :
commandes_entity
commandes_ligne_entity ( entity reference to commandes_entity )
The only way i have found is to create a hook_entity_delete :
Edit : This is how i delete children :
function boutique_commandes_entity_delete(DrupalCoreEntityEntityInterface $entity) { $query = Drupal::database()->delete('commandes_lignes_entity'); $query->condition('commandes_id', $entity->get('id')->value); $query->execute(); }
Is there another way (maybe better) for delete children ?