Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
added config field and hook
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Jun 27, 2024
1 parent 747a7c7 commit 0500751
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
uuid: e5f78d8d-be86-4b79-b6ab-f39819760687
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_additional_comment
- taxonomy.vocabulary.sites
module:
- allowed_formats
- text
third_party_settings:
allowed_formats:
allowed_formats: { }
id: taxonomy_term.sites.field_additional_comment
field_name: field_additional_comment
entity_type: taxonomy_term
bundle: sites
label: 'Additional comment'
description: ''
required: false
translatable: false
default_value:
-
value: '<p><span>If you need a response, please use our </span><a class="rpl-text-link rpl-u-focusable-inline" href="https://www.vic.gov.au/contact-us">contact us form</a><span>.</span></p>'
format: rich_text
default_value_callback: ''
settings:
allowed_formats: { }
field_type: text_long
1 change: 1 addition & 0 deletions tests/behat/features/sites.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Feature: Sites taxonomy vocabulary
And I see field "Slogan"
And I see field "Logo"
And I see field "Footer text"
And I see field "Additional comment"
And I see field "Domains"
And I see field "Main menu"
And I see field "Footer menu"
Expand Down
32 changes: 32 additions & 0 deletions tide_site.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Install file for tide_site.
*/

use Drupal\Component\Utility\NestedArray;

/**
* Implements hook_install().
*/
Expand All @@ -17,3 +19,33 @@ function tide_site_install() {
}
}
}

/**
* New field taxonomy image logo.
*/
function tide_site_update_10001() {
$configs = [
'field.field.taxonomy_term.sites.field_additional_comment' => 'field_config',
];
module_load_include('inc', 'tide_core', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_site') . '/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 = substr($config, strrpos($config, '.') + 1);
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
}
$data = $config->getRawData();
foreach ($config_read as $key => $item) {
NestedArray::setValue($data, [
$key,
], NestedArray::getValue($config_read, [
$key,
]));
}
$config->setData($data)->save();
}

0 comments on commit 0500751

Please sign in to comment.