You are here

public static function Conditions::baseFieldDefinitions in Legal 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Conditions.php \Drupal\legal\Entity\Conditions::baseFieldDefinitions()

Define the field properties here.

Field name, type and size determine the table structure.

In addition, we can define how the field and its content can be manipulated in the GUI. The behaviour of the widgets used can be determined here.

Overrides ContentEntityBase::baseFieldDefinitions

File

src/Entity/Conditions.php, line 94

Class

Conditions
Defines the Legal Terms & Conditions entity.

Namespace

Drupal\legal\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {

  // Standard field, used as unique if primary index.
  $fields['tc_id'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('ID'))
    ->setDescription(t('The ID of the Terms & Conditions.'))
    ->setReadOnly(TRUE);

  // Standard field, unique outside of the scope of the current project.
  $fields['uuid'] = BaseFieldDefinition::create('uuid')
    ->setLabel(t('UUID'))
    ->setDescription(t('The UUID of the Terms & Conditions.'))
    ->setReadOnly(TRUE);
  $fields['version'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('Version'))
    ->setDescription(t('The version number of the Terms & Conditions.'));
  $fields['revision'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('Revision'))
    ->setDescription(t('The revision number of the Terms & Conditions.'));
  $fields['language'] = BaseFieldDefinition::create('language')
    ->setLabel(t('Language code'))
    ->setDescription(t('Language code of the language this applies to.'));
  $fields['conditions'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Terms & Conditions'))
    ->setDescription(t('Terms & Conditions text.'));
  $fields['format'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Format'))
    ->setDescription(t('Input Format of Terms & Conditions text.'));
  $fields['date'] = BaseFieldDefinition::create('created')
    ->setLabel(t('Created'))
    ->setDescription(t('When the Terms & Conditions were created.'));
  $fields['extras'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Extras'))
    ->setDescription(t('Additional conditions (checkboxes).'));
  $fields['changes'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Changes'))
    ->setDescription(t('Explanation of changes to T&C since last version.'));
  return $fields;
}