Commit 111a3105 authored by RoSk0's avatar RoSk0

Added relation cleanup if contact deleted.

parent 82bd9c90
......@@ -7,6 +7,7 @@
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\crm_core_contact\Entity\Individual;
use Drupal\crm_core_contact\IndividualInterface;
use Drupal\crm_core_user_sync\Entity\Relation;
use Drupal\user\UserInterface;
......@@ -46,6 +47,17 @@ function crm_core_user_sync_user_delete(UserInterface $account) {
}
}
/**
* Implements hook_crm_core_individual_delete().
*/
function crm_core_user_sync_crm_core_individual_delete(IndividualInterface $individual) {
$relation_id = \Drupal::service('crm_core_user_sync.relation')->getIndividualRelationId($individual->id());
if ($relation_id) {
$relation = Relation::load($relation_id);
$relation->delete();
}
}
/**
* Implements hook_entity_extra_field_info().
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment