forked from xenomedia/xeno_hero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xeno_hero.install
78 lines (63 loc) · 3.23 KB
/
xeno_hero.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
/**
* @file
* Install / Update functions for Xeno Hero.
*/
use Symfony\Component\Yaml\Yaml;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Config\FileStorage;
/**
* Adds offset field to Hero paragraph.
*/
function xeno_hero_update_8001() {
$module_handler = \Drupal::moduleHandler();
$config_storage = new FileStorage($module_handler->getModule('xeno_hero')->getPath() . '/config/install');
foreach (['field.storage.paragraph.xeno_offset', 'field.field.paragraph.xeno_hero.xeno_offset'] as $config_name) {
$config_record = $config_storage->read($config_name);
$entity_type = \Drupal::service('config.manager')->getEntityTypeIdByName($config_name);
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entity = $storage->createFromStorageRecord($config_record);
$entity->save();
}
// Send message to updater.
$message = t('Offset field added to the hero bundle. It allows you to modify the position of the background image. Navigate to the Manage form display and Manage display for Hero to enable the offset field.');
return $message;
}
/**
* Adds size field to Hero paragraph.
*/
function xeno_hero_update_8002() {
$module_handler = \Drupal::moduleHandler();
$config_storage = new FileStorage($module_handler->getModule('xeno_hero')->getPath() . '/config/install');
foreach (['field.storage.paragraph.xeno_size', 'field.field.paragraph.xeno_hero.xeno_size'] as $config_name) {
$config_record = $config_storage->read($config_name);
$entity_type = \Drupal::service('config.manager')->getEntityTypeIdByName($config_name);
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entity = $storage->createFromStorageRecord($config_record);
$entity->save();
}
// Send message to updater.
$message = t('Size field added to the hero bundle. It allows you to modify the size of the background image (contain or cover). Navigate to the Manage form display and Manage display for Hero to enable the size field.');
return $message;
}
/**
* Adds attachment field to Hero paragraph.
*/
function xeno_hero_update_8003() {
$module_handler = \Drupal::moduleHandler();
$config_storage = new FileStorage($module_handler->getModule('xeno_hero')->getPath() . '/config/install');
foreach (['field.storage.paragraph.xeno_attachment', 'field.field.paragraph.xeno_hero.xeno_attachment'] as $config_name) {
$config_record = $config_storage->read($config_name);
$entity_type = \Drupal::service('config.manager')->getEntityTypeIdByName($config_name);
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entity = $storage->createFromStorageRecord($config_record);
$entity->save();
}
// Send message to updater.
$message = t('Attachment field added to the hero bundle. It allows you to modify the attachment of the background image (scroll or fixed). Navigate to the Manage form display and Manage display for Hero to enable the attachment field.');
return $message;
}