public static function Job::baseFieldDefinitions

File

src/Entity/Job.php, line 62

Class

Job
Entity class for the tmgmt_job entity.

Namespace

Drupal\tmgmt\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields['tjid'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('Job ID'))
    ->setDescription(t('The Job ID.'))
    ->setReadOnly(TRUE)
    ->setSetting('unsigned', TRUE);
  $fields['uuid'] = BaseFieldDefinition::create('uuid')
    ->setLabel(t('UUID'))
    ->setDescription(t('The node UUID.'))
    ->setReadOnly(TRUE);
  $fields['source_language'] = BaseFieldDefinition::create('language')
    ->setLabel(t('Source language code'))
    ->setDescription(t('The source language.'));
  $fields['target_language'] = BaseFieldDefinition::create('language')
    ->setLabel(t('Target language code'))
    ->setDescription(t('The target language.'));
  $fields['label'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Label'))
    ->setDescription(t('The label of this job.'))
    ->setDefaultValue('')
    ->setSettings(array(
    'max_length' => 255,
  ))
    ->setDisplayOptions('form', array(
    'type' => 'string',
    'weight' => -5,
  ))
    ->setDisplayConfigurable('form', TRUE);
  $fields['uid'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Owner'))
    ->setDescription(t('The user that is the job owner.'))
    ->setSettings(array(
    'target_type' => 'user',
  ))
    ->setDefaultValue(0);
  $fields['translator'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Provider'))
    ->setDescription(t('The selected provider'))
    ->setSettings(array(
    'target_type' => 'tmgmt_translator',
  ));
  $fields['settings'] = BaseFieldDefinition::create('map')
    ->setLabel(t('Settings'))
    ->setDescription(t('Provider specific configuration and context information for this job.'))
    ->setDefaultValue(array());
  $fields['reference'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Reference'))
    ->setDescription(t('Remote reference of this job'))
    ->setDefaultValue('')
    ->setSettings(array(
    'max_length' => 255,
  ));
  $fields['state'] = BaseFieldDefinition::create('list_integer')
    ->setLabel(t('Job state'))
    ->setDescription(t('The job state.'))
    ->setSetting('allowed_values', Job::getStates())
    ->setDefaultValue(Job::STATE_UNPROCESSED);
  $fields['created'] = BaseFieldDefinition::create('created')
    ->setLabel(t('Created'))
    ->setDescription(t('The time that the job was created.'));
  $fields['changed'] = BaseFieldDefinition::create('changed')
    ->setLabel(t('Changed'))
    ->setDescription(t('The time that the job was last edited.'));
  $fields['job_type'] = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Job type'))
    ->setDescription(t('Type of job entity, can be Normal or Continuous.'))
    ->setSetting('allowed_values', [
    static::TYPE_NORMAL,
    static::TYPE_CONTINUOUS,
  ])
    ->setDefaultValue(static::TYPE_NORMAL);
  $fields['continuous_settings'] = BaseFieldDefinition::create('map')
    ->setLabel(t('Continuous settings'))
    ->setDescription(t('Continuous sources configuration.'))
    ->setDefaultValue(array());
  return $fields;
}