forked from thunder/paragraphs_features
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparagraphs_features.install
34 lines (30 loc) · 1.02 KB
/
paragraphs_features.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* @file
* Contains update hooks for Paragraphs Feature module.
*/
/**
* Remove split_text key from all entity form displays.
*/
function paragraphs_features_update_9001() {
$entity_form_display_storage = \Drupal::entityTypeManager()->getStorage('entity_form_display');
$entity_form_displays = $entity_form_display_storage->loadMultiple();
foreach ($entity_form_displays as $entity_form_display) {
$save = FALSE;
$content = $entity_form_display->get('content');
foreach ($content as $field_name => $field) {
// Continue if the field is not a paragraphs field.
if (!isset($field['type']) || $field['type'] !== 'paragraphs') {
continue;
}
if (isset($field['third_party_settings']['paragraphs_features']['split_text'])) {
unset($content[$field_name]['third_party_settings']['paragraphs_features']['split_text']);
$save = TRUE;
}
}
if ($save) {
$entity_form_display->set('content', $content);
$entity_form_display->save();
}
}
}