You are here

function easy_email_field_add_bcc_uid_field in Easy Email 8

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

File

./easy_email.module, line 488
Contains easy_email.module.

Code

function easy_email_field_add_bcc_uid_field(EasyEmailTypeInterface $easy_email_type) {
  $field_definition = BaseFieldDefinition::create('entity_reference')
    ->setTargetEntityTypeId('easy_email')
    ->setTargetBundle($easy_email_type
    ->id())
    ->setName('bcc_uid')
    ->setLabel(t('BCC'))
    ->setRevisionable(TRUE)
    ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
    ->setRequired(FALSE)
    ->setSetting('target_type', 'user')
    ->setSetting('handler', 'default')
    ->setTranslatable(TRUE)
    ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'author',
    'weight' => 0,
  ])
    ->setDisplayOptions('form', [
    'type' => 'entity_reference_autocomplete',
    'weight' => 5,
    'settings' => [
      'match_operator' => 'CONTAINS',
      'size' => '60',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ],
  ])
    ->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
  }
}