You are here

function opigno_certificate_update_80022 in Opigno certificate 8

Creates the paper_orientation field in opigno_certificate.

File

./opigno_certificate.install, line 75
Install, update and uninstall functions for the Opigno Certificate module.

Code

function opigno_certificate_update_80022() {
  $field = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Paper Orientation'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDefaultValue('portrait')
    ->setSetting('allowed_values', [
    'portrait' => t('Portrait'),
    'landscape' => t('Landscape'),
  ])
    ->setDisplayOptions('form', [
    'type' => 'options_buttons',
    'weight' => -5,
  ]);
  $definition_manager = \Drupal::entityDefinitionUpdateManager();
  $definition_manager
    ->installFieldStorageDefinition('paper_orientation', 'opigno_certificate', 'opigno_certificate', $field);
  $config_path = drupal_get_path('module', 'opigno_certificate') . '/config/install';
  $storage = new FileStorage($config_path);
  $config_storage = \Drupal::service('config.storage');
  $data = $storage
    ->read('core.entity_form_display.opigno_certificate.wysiwyg.default');
  $config_storage
    ->write('core.entity_form_display.opigno_certificate.wysiwyg.default', $data);
}