You are here

function easy_email_field_add_html_body_field in Easy Email 8

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

File

./easy_email.module, line 616
Contains easy_email.module.

Code

function easy_email_field_add_html_body_field(EasyEmailTypeInterface $easy_email_type) {
  $field_definition = BaseFieldDefinition::create('text_long')
    ->setTargetEntityTypeId('easy_email')
    ->setTargetBundle($easy_email_type
    ->id())
    ->setName('body_html')
    ->setLabel(t('HTML Body'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDisplayOptions('form', [
    'type' => 'text_textarea',
    'weight' => 0,
  ])
    ->setDisplayOptions('view', [
    'type' => 'text_default',
    '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
  }
}