You are here

function easy_email_field_add_inbox_preview_field in Easy Email 8

Same name and namespace in other branches
  1. 2.0.x easy_email.module \easy_email_field_add_inbox_preview_field()
1 call to easy_email_field_add_inbox_preview_field()
easy_email_entity_insert in ./easy_email.module

File

./easy_email.module, line 680
Contains easy_email.module.

Code

function easy_email_field_add_inbox_preview_field(EasyEmailTypeInterface $easy_email_type) {
  $field_definition = BaseFieldDefinition::create('string_long')
    ->setTargetEntityTypeId('easy_email')
    ->setTargetBundle($easy_email_type
    ->id())
    ->setName('inbox_preview')
    ->setLabel(t('Inbox Preview'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDisplayOptions('form', [
    'type' => 'string_textarea',
    'weight' => 0,
  ])
    ->setDisplayOptions('view', [
    'type' => 'basic_string',
    'weight' => 0,
    'label' => 'hidden',
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);
  try {
    easy_email_create_field($field_definition, FALSE);
  } catch (\RuntimeException $e) {

    // In this case, field already exists from installation
  } catch (EntityStorageException $e) {

    // In this case, field already exists from installation
  }
}