You are here

function allowed_languages_entity_base_field_info in Allowed Languages 2.x

Same name and namespace in other branches
  1. 8 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) {
  if ($entity_type
    ->id() !== 'user') {
    return [];
  }
  $fields = [];

  // 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;
}