You are here

function sharedemail_entity_base_field_info_alter in Shared Email 8.2

Implements hook_entity_base_field_info_alter().

Removes the unique constraint for the email address.

File

./sharedemail.module, line 27
Shared email module file.

Code

function sharedemail_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {

  // Alter the email text field to allow duplicates.
  if (!empty($fields['mail']) && $entity_type
    ->id() === 'user') {
    $constraints = $fields['mail']
      ->getConstraints();
    unset($constraints['UserMailUnique']);
    $constraints['SharedEmailUnique'] = [];
    $fields['mail']
      ->setConstraints($constraints);
  }
}