leshed_helpers_taxonomy_term_delete

This commit is contained in:
2026-10-20 17:24:42 +02:00
parent 82ee0fd7dd
commit 38be780911
@@ -30,6 +30,24 @@ function leshed_helpers_taxonomy_term_update(EntityInterface $entity) {
leshed_helpers_ensure_term_alias($entity);
}
/**
* Supprime l'alias d'URL quand un terme d'un vocabulaire géré est supprimé.
*/
function leshed_helpers_taxonomy_term_delete(EntityInterface $entity) {
if (!($entity instanceof TermInterface)) {
return;
}
$vid = $entity->bundle();
if (!isset(LESHED_HELPERS_VOCABULARIES[$vid])) {
return;
}
$internal_path = '/' . LESHED_HELPERS_VOCABULARIES[$vid] . '/' . $entity->id();
$storage = \Drupal::entityTypeManager()->getStorage('path_alias');
$storage->delete($storage->loadByProperties(['path' => $internal_path]));
}
function leshed_helpers_ensure_term_alias(EntityInterface $entity) {
if (!($entity instanceof TermInterface)) {
return;