'EntityAuditBundle / Prevent DEL entry on Integrity constraint violation

I use the Sonata-Projects EntityAuditBundle in a API platform project to get a history for certain entities.

When attempting to delete a particular entity, it may not be possible to delete it because it's being used by another entity. In such a case, an exception (Integrity constraint violation) is thrown and the original entity is not deleted.
However a 'DEL' entry is automatically generated by the EntityAuditBundle in the corresponding audit table, which must not happen. Can anyone give me a tip on how to prevent this?

My config\packages\entity_audit.yaml file looks like:

simple_things_entity_audit:
  audited_entities:
    - App\Entity\CostCenter
    - App\Entity\CostUnit
    - App\Entity\Employee

Thank you very much and best regards from Germany, Thomas



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source