This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6c7b51
commit f8fc49a
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |