-
Notifications
You must be signed in to change notification settings - Fork 1
/
iform_layout_builder.install
78 lines (73 loc) · 2.99 KB
/
iform_layout_builder.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Config\FileStorage;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Adds configuration for the RESTful resource for reading a survey form.
*/
function iform_layout_builder_update_8801() {
$path = \Drupal::service('extension.path.resolver')->getPath('module', 'iform_layout_builder') . '/config/install';
$source = new FileStorage($path);
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$active_storage->write('rest.resource.indicia_form_layout', $source->read('rest.resource.indicia_form_layout'));
}
/**
* Adds configuration for the RESTful resource for reading a survey form list.
*/
function iform_layout_builder_update_8802() {
$path = \Drupal::service('extension.path.resolver')->getPath('module', 'iform_layout_builder') . '/config/install';
$source = new FileStorage($path);
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$active_storage->write('rest.resource.indicia_form_layout_list', $source->read('rest.resource.indicia_form_layout_list'));
}
/**
* Adds new fields to forms for managing the sample method.
*/
function iform_layout_builder_update_9200() {
$modulePath = \Drupal::service('extension.list.module')->getPath('iform_layout_builder');
$configSettings = Yaml::decode(file_get_contents(
"$modulePath/config/install/field.storage.node.field_sample_method_id.yml"
));
$fieldStorage = FieldStorageConfig::create($configSettings);
$fieldStorage->save();
$configSettings = Yaml::decode(file_get_contents(
"$modulePath/config/install/field.storage.node.field_child_sample_method_id.yml"
));
$fieldStorage = FieldStorageConfig::create($configSettings);
$fieldStorage->save();
$configSettings = Yaml::decode(file_get_contents(
"$modulePath/config/install/field.field.node.iform_layout_builder_form.field_sample_method_id.yml"
));
$field = FieldConfig::create($configSettings);
$field->save();
$configSettings = Yaml::decode(file_get_contents(
"$modulePath/config/install/field.field.node.iform_layout_builder_form.field_child_sample_method_id.yml"
));
$field = FieldConfig::create($configSettings);
$field->save();
$properties = [
'targetEntityType' => 'node',
'bundle' => 'iform_layout_builder_form'
];
if ($formDisplays = \Drupal::entityTypeManager()->getStorage('entity_form_display')->loadByProperties($properties)) {
foreach ($formDisplays as $formDisplay) {
$formDisplay->setComponent('field_sample_method_id', [
'weight' => 10,
'type' => 'number',
'region' => 'content',
]);
$formDisplay->setComponent('field_child_sample_method_id', [
'weight' => 11,
'type' => 'number',
'region' => 'content',
]);
$formDisplay->setComponent('field_template', [
'weight' => 12,
]);
$formDisplay->save();
}
}
}