You are here

function votingapi_widgets_entity_base_field_info in Votingapi Widgets 8

Implements hook_entity_base_field_info().

File

./votingapi_widgets.module, line 34
Contains votingapi_widgets.module..

Code

function votingapi_widgets_entity_base_field_info(EntityTypeInterface $entity_type) {

  // Add the field_name as a base field.
  if ($entity_type
    ->id() != 'vote') {
    return;
  }
  $fields = [];
  $fields['field_name'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Field name'))
    ->setName('field_name')
    ->setRevisionable(FALSE)
    ->setRequired(FALSE)
    ->setDescription(t('Holds the field name.'))
    ->setPropertyConstraints('value', [
    'Length' => [
      'max' => FieldStorageConfig::NAME_MAX_LENGTH,
    ],
  ]);
  return $fields;
}