From 152c4c08e66cfd018c12577149b97491dea43b00 Mon Sep 17 00:00:00 2001 From: Taras Kravchuk <58949-tarik@users.noreply.drupalcode.org> Date: Fri, 15 Dec 2023 02:10:32 +0200 Subject: [PATCH] Issue #3408925: Added insert/update/delete hooks for domain path entity to provide way decoupled route cache invalidation --- domain_path.module | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/domain_path.module b/domain_path.module index 33e80c8..b67074c 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()]); + } +} -- GitLab