Skip to content
Snippets Groups Projects
Commit 152c4c08 authored by Taras Kravchuk's avatar Taras Kravchuk Committed by Taras Kravchuk
Browse files

Issue #3408925: Added insert/update/delete hooks for domain path entity to...

Issue #3408925: Added insert/update/delete hooks for domain path entity to provide way decoupled route cache invalidation
parent 64f5e2d9
Branches
Tags
1 merge request!22Issue #3408925: Added insert/update/delete hooks for domain path entity to...
......@@ -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()]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment