From 9778b28abb955ea6a763ee06661af5c31bf508e0 Mon Sep 17 00:00:00 2001 From: Prashant Kanse Date: Thu, 18 Jan 2024 17:48:38 +0530 Subject: [PATCH] DGIR-148 : Fix update hook issue --- embargo.install | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/embargo.install b/embargo.install index b97da50..bb5dda8 100644 --- a/embargo.install +++ b/embargo.install @@ -6,7 +6,7 @@ */ use Drupal\Core\Field\BaseFieldDefinition; -use Drupal\Core\Update\UpdateException; +use Drupal\Core\Utility\UpdateException; /** * Add a new field to the existing Embargo entity type. @@ -20,16 +20,13 @@ function embargo_update_8001() { try { // Create a new field definition. $new_field = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('New Embargoed File')) + ->setLabel(t('Embargoed File')) ->setDescription(t('New field for attaching media to the Embargo node.')) ->setSetting('target_type', 'media') ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED); // Install the new definition. - $definition_manager->installFieldStorageDefinition('new_embargoed_file', $entity_type_id, $bundle, $new_field); - - // Clear the cache. - drupal_flush_all_caches(); + $definition_manager->installFieldStorageDefinition('embargoed_file', $entity_type_id, $bundle, $new_field); } catch (UpdateException $e) { // Handle exception if needed. @@ -38,5 +35,5 @@ function embargo_update_8001() { } // Provide a message indicating the update has been applied. - return t('Added new_embargoed_file to the Embargo entity.'); + return t('Added embargoed_file to the Embargo entity.'); }