From dfc8068b00340c719f633206928f42af812cbd7d Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Wed, 28 Aug 2024 21:50:08 +1000 Subject: [PATCH] added hook update --- ...rm_display.taxonomy_term.sites.default.yml | 9 ---- ...ew_display.taxonomy_term.sites.default.yml | 9 ---- ...d.taxonomy_term.sites.field_short_name.yml | 19 -------- ...storage.taxonomy_term.field.short_name.yml | 21 --------- .../tide_site_theming.install | 44 +++++++++++++++++++ 5 files changed, 44 insertions(+), 58 deletions(-) delete mode 100644 config/install/field.field.taxonomy_term.sites.field_short_name.yml delete mode 100644 config/install/field.storage.taxonomy_term.field.short_name.yml diff --git a/config/install/core.entity_form_display.taxonomy_term.sites.default.yml b/config/install/core.entity_form_display.taxonomy_term.sites.default.yml index 4827cb4..fe3942c 100644 --- a/config/install/core.entity_form_display.taxonomy_term.sites.default.yml +++ b/config/install/core.entity_form_display.taxonomy_term.sites.default.yml @@ -6,7 +6,6 @@ dependencies: - field.field.taxonomy_term.sites.field_acknowledgement_to_country - field.field.taxonomy_term.sites.field_additional_comment - field.field.taxonomy_term.sites.field_bottom_corner_graphic - - field.field.taxonomy_term.sites.field_short_name - field.field.taxonomy_term.sites.field_site_app_icon - field.field.taxonomy_term.sites.field_print_friendly_logo - field.field.taxonomy_term.sites.field_prominence_ack_to_country @@ -186,14 +185,6 @@ content: settings: display_label: true third_party_settings: { } - field_short_name: - type: string_textfield - weight: 24 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } field_site_app_icon: type: image_image weight: 25 diff --git a/config/install/core.entity_view_display.taxonomy_term.sites.default.yml b/config/install/core.entity_view_display.taxonomy_term.sites.default.yml index 8d8a192..292a8c3 100644 --- a/config/install/core.entity_view_display.taxonomy_term.sites.default.yml +++ b/config/install/core.entity_view_display.taxonomy_term.sites.default.yml @@ -6,7 +6,6 @@ dependencies: - field.field.taxonomy_term.sites.field_additional_comment - field.field.taxonomy_term.sites.field_print_friendly_logo - field.field.taxonomy_term.sites.field_prominence_ack_to_country - - field.field.taxonomy_term.sites.field_short_name - field.field.taxonomy_term.sites.field_site_app_icon - field.field.taxonomy_term.sites.field_show_table_of_contents - field.field.taxonomy_term.sites.field_site_domains @@ -40,14 +39,6 @@ content: third_party_settings: { } weight: 9 region: content - field_short_name: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 22 - region: content field_site_app_icon: type: image label: above diff --git a/config/install/field.field.taxonomy_term.sites.field_short_name.yml b/config/install/field.field.taxonomy_term.sites.field_short_name.yml deleted file mode 100644 index 95813a5..0000000 --- a/config/install/field.field.taxonomy_term.sites.field_short_name.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: 25ae7415-ab3a-41e3-9bb2-662ea5b4ce73 -langcode: en -status: true -dependencies: - config: - - field.storage.taxonomy_term.field_short_name - - taxonomy.vocabulary.sites -id: taxonomy_term.sites.field_short_name -field_name: field_short_name -entity_type: taxonomy_term -bundle: sites -label: 'Field short name' -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/install/field.storage.taxonomy_term.field.short_name.yml b/config/install/field.storage.taxonomy_term.field.short_name.yml deleted file mode 100644 index 7e20105..0000000 --- a/config/install/field.storage.taxonomy_term.field.short_name.yml +++ /dev/null @@ -1,21 +0,0 @@ -uuid: 0323655e-547a-42e4-b94c-f868a41dcc8e -langcode: en -status: true -dependencies: - module: - - taxonomy -id: taxonomy_term.field_short_name -field_name: field_short_name -entity_type: taxonomy_term -type: string -settings: - max_length: 12 - case_sensitive: false - is_ascii: false -module: core -locked: false -cardinality: 1 -translatable: true -indexes: { } -persist_with_no_fields: false -custom_storage: false diff --git a/modules/tide_site_theming/tide_site_theming.install b/modules/tide_site_theming/tide_site_theming.install index 61fedd0..daffdfb 100644 --- a/modules/tide_site_theming/tide_site_theming.install +++ b/modules/tide_site_theming/tide_site_theming.install @@ -215,3 +215,47 @@ function tide_site_theming_update_8001() { } $config->save(); } + +/** + * Add site app icon field. + */ +function tide_site_theming_update_10001() { + $configs = [ + 'field.storage.taxonomy_term.field_site_app_icon' => 'field_storage_config', + 'field.field.taxonomy_term.sites.field_site_app_icon' => 'field_config', + ]; + module_load_include('inc', 'tide_core', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_site_theming') . '/config/install']; + // Check if field already exported to config/sync. + foreach ($configs as $config => $type) { + $config_read = _tide_read_config($config, $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage($type); + $id = $storage->getIDFromConfigName($config, $storage->getEntityType()->getConfigPrefix()); + if ($storage->load($id) == NULL) { + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + } + + // Add to JSON. + $config_factory = \Drupal::configFactory(); + $config = $config_factory->getEditable('jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites'); + $resourcefields_fields = [ + 'field_site_app_icon', + ]; + $content = $config->get('resourceFields'); + foreach ($resourcefields_fields as $field) { + if (!isset($content[$field])) { + $content[$field] = [ + 'fieldName' => $field, + 'publicName' => $field, + 'enhancer' => [ + 'id' => '', + ], + 'disabled' => FALSE, + ]; + $config->set('resourceFields', $content); + } + } + $config->save(); +}