You are here

function apigee_edge_entity_base_field_info_alter in Apigee Edge 8

Implements hook_entity_base_field_info_alter().

File

./apigee_edge.module, line 322
Copyright 2018 Google Inc.

Code

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

  /** @var \Drupal\Core\Field\FieldDefinitionInterface[] $fields */
  if ($entity_type
    ->id() === 'user') {

    /** @var \Drupal\Core\Field\BaseFieldDefinition $mail */
    $mail = $fields['mail'];
    $mail
      ->setRequired(TRUE);
    $mail
      ->addConstraint('DeveloperMailUnique');

    // Add a bundle to these fields to allow other modules to display them
    // as configurable (fields added through the UI or configuration do have a
    // target bundle set).
    // @see https://github.com/apigee/apigee-edge-drupal/issues/396
    $fields['first_name']
      ->setTargetBundle('user');
    $fields['last_name']
      ->setTargetBundle('user');
  }
}