From e62a8e7c69e41418301cfaa263187c60eb81e3d9 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Mon, 26 Feb 2024 15:17:56 +0200 Subject: [PATCH] UHF-9446: Add update hook that removes district listing paragraphs from the database --- .../helfi_kymp_content.install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/modules/custom/helfi_kymp_content/helfi_kymp_content.install b/public/modules/custom/helfi_kymp_content/helfi_kymp_content.install index ed006e107..34a4ac01e 100644 --- a/public/modules/custom/helfi_kymp_content/helfi_kymp_content.install +++ b/public/modules/custom/helfi_kymp_content/helfi_kymp_content.install @@ -13,3 +13,19 @@ declare(strict_types=1); function helfi_kymp_content_update_9001(): void { _helfi_kymp_content_create_district_nodes_from_taxonomy_terms(); } + +/** + * UHF-9446: Remove all district listing paragraphs. + */ +function helfi_kymp_content_update_9002(): void { + $storage = \Drupal::entityTypeManager() + ->getStorage('paragraph'); + $entityIds = $storage->getQuery() + ->condition('type', 'district_listing') + ->accessCheck(FALSE) + ->execute(); + + foreach ($entityIds as $id) { + $storage->load($id)->delete(); + } +}