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

Commit

Permalink
added hook update
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Mar 27, 2024
1 parent c6c7b51 commit f8fc49a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tide_data_driven_component.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @file
* Tide Data Driven Component module install file.
*/

/**
* Adds json text area field to data driven component.
*/
function tide_data_driven_component_update_10001() {
module_load_include('inc', 'tide_core', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_data_driven_component') . '/config/install'];

$configs = [
'field.storage.paragraph.field_configuration' => 'field_storage_config',
'field.field.paragraph.data_driven_component.field_configuration' => 'field_config',
];
// 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);
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}

$form_configs = [
'core.entity_form_display.paragraph.data_driven_component.default',
'core.entity_view_display.paragraph.data_driven_component.default',
];
foreach ($form_configs as $form_config) {
$config = \Drupal::configFactory()->getEditable($form_config);
$config_read = _tide_read_config($form_config, $config_location, FALSE);
$config->set('dependencies', $config_read['dependencies']);
$config->set('content', $config_read['content']);
$config->set('hidden', $config_read['hidden']);
$config->save();
}
}

0 comments on commit f8fc49a

Please sign in to comment.