You are here

function allowed_languages_entity_base_field_info in Allowed Languages 8

Same name and namespace in other branches
  1. 2.x allowed_languages.module \allowed_languages_entity_base_field_info()

Implements hook_entity_base_field_info().

File

./allowed_languages.module, line 36
Contains allowed_languages.module.

Code

function allowed_languages_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  if ($entity_type
    ->id() === 'user') {

    // Add the allowed languages entity reference field to the user entity.
    $fields['allowed_languages'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Allowed languages'))
      ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
      ->setDescription(t('The languages the user is allowed to manage.'))
      ->setSetting('target_type', 'configurable_language');
  }
  return $fields;
}