-
Notifications
You must be signed in to change notification settings - Fork 1
/
ewp_institutions.install
44 lines (39 loc) · 1.1 KB
/
ewp_institutions.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
<?php
/**
* @file
* Contains install, update and uninstall hooks.
*/
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Increase the max length of the entity label to 255 characters.
*/
function ewp_institutions_update_8101() {
$field_spec = [
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
];
\Drupal::database()->schema()->changeField('hei', 'label', 'label', $field_spec);
$definition = BaseFieldDefinition::create('string')
->setLabel(t('Label'))
->setDescription(t('The internal label of the Institution entity.'))
->setSettings([
'max_length' => 255,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -20,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -20,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('label', 'hei', 'hei', $definition);
}