diff --git a/domain_path.module b/domain_path.module index 33e80c858cec06556b3438e13d227f52b0f4e83e..b67074c3f9653eecfd1fae78f51f10abd39635d1 100755 --- a/domain_path.module +++ b/domain_path.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\domain_path\DomainPathInterface; /** * Implements hook_form_alter(). @@ -36,3 +37,33 @@ function domain_path_entity_delete(EntityInterface $entity) { function domain_path_entity_translation_delete(EntityInterface $translation) { \Drupal::service('domain_path.helper')->deleteEntityDomainPaths($translation); } + +/** + * Implements hook_ENTITY_TYPE_insert(). + */ +function domain_path_domain_path_insert(DomainPathInterface $path) { + if (\Drupal::hasService('decoupled_router.cache_invalidation')) { + \Drupal::service('decoupled_router.cache_invalidation') + ->invalidateByPath(['source' => $path->getAlias()]); + } +} + +/** + * Implements hook_ENTITY_TYPE_update(). + */ +function domain_path_domain_path_update(DomainPathInterface $path) { + if (\Drupal::hasService('decoupled_router.cache_invalidation')) { + \Drupal::service('decoupled_router.cache_invalidation') + ->invalidateByPath(['source' => $path->getAlias()]); + } +} + +/** + * Implements hook_ENTITY_TYPE_delete(). + */ +function domain_path_domain_path_delete(DomainPathInterface $path) { + if (\Drupal::hasService('decoupled_router.cache_invalidation')) { + \Drupal::service('decoupled_router.cache_invalidation') + ->invalidateByPath(['source' => $path->getAlias()]); + } +}