You are here

function easy_email_field_add_attachment_path_field in Easy Email 8

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

File

./easy_email.module, line 712
Contains easy_email.module.

Code

function easy_email_field_add_attachment_path_field(EasyEmailTypeInterface $easy_email_type) {
  $field_definition = BaseFieldDefinition::create('string')
    ->setTargetEntityTypeId('easy_email')
    ->setTargetBundle($easy_email_type
    ->id())
    ->setName('attachment_path')
    ->setLabel(t('Attachment Paths'))
    ->setRevisionable(TRUE)
    ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
    ->setRequired(FALSE)
    ->setSettings([
    'max_length' => 255,
    'text_processing' => 0,
  ])
    ->setDefaultValue('')
    ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ])
    ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    'weight' => -4,
  ])
    ->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
  }
}