function ds_switch_view_mode_entity_base_field_info in Display Suite 8.4
Same name and namespace in other branches
- 8.2 modules/ds_switch_view_mode/ds_switch_view_mode.module \ds_switch_view_mode_entity_base_field_info()
- 8.3 modules/ds_switch_view_mode/ds_switch_view_mode.module \ds_switch_view_mode_entity_base_field_info()
Implements hook_entity_base_field_info().
File
- modules/
ds_switch_view_mode/ ds_switch_view_mode.module, line 18 - Display Suite Switch View mode.
Code
function ds_switch_view_mode_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type
->id() == 'node') {
// Add the switch field as a base field.
$fields = [];
$fields['ds_switch'] = BaseFieldDefinition::create('string')
->setLabel(t('DS switch'))
->setName('ds_switch')
->setRevisionable(TRUE)
->setDescription(t('Holds the DS view mode of the node.'))
->setSetting('default_value', '')
->setPropertyConstraints('value', [
'Length' => [
'max' => 60,
],
]);
return $fields;
}
}