public static function LocalTaskItem::baseFieldDefinitions in Translation Management Tool 8
Provides base field definitions for an entity type.
Implementations typically use the class \Drupal\Core\Field\BaseFieldDefinition for creating the field definitions; for example a 'name' field could be defined as the following:
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'));
By definition, base fields are fields that exist for every bundle. To provide definitions for fields that should only exist on some bundles, use \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions().
The definitions returned by this function can be overridden for all bundles by hook_entity_base_field_info_alter() or overridden on a per-bundle basis via 'base_field_override' configuration entities.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition. Useful when a single class is used for multiple, possibly dynamic entity types.
Return value
\Drupal\Core\Field\FieldDefinitionInterface[] An array of base field definitions for the entity type, keyed by field name.
Overrides ContentEntityBase::baseFieldDefinitions
See also
\Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions()
\Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions()
File
- translators/
tmgmt_local/ src/ Entity/ LocalTaskItem.php, line 58
Class
- LocalTaskItem
- Entity class for the local task item entity.
Namespace
Drupal\tmgmt_local\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['tltiid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Local Task Item ID'))
->setDescription(t('The Local Task Item ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['tltid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Local task'))
->setDescription(t('The local task.'))
->setReadOnly(TRUE)
->setSetting('target_type', 'tmgmt_local_task');
$fields['tjiid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Job Item'))
->setDescription(t('The Job Item.'))
->setReadOnly(TRUE)
->setSetting('target_type', 'tmgmt_job_item');
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The job item UUID.'))
->setReadOnly(TRUE);
$fields['data'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Data'))
->setDescription(t('The source data'));
$fields['status'] = BaseFieldDefinition::create('integer')
->setLabel(t('Local task item status'))
->setDescription(t('The local task item status'))
->setDefaultValue(LocalTaskItemInterface::STATUS_PENDING);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the job was last edited.'));
$fields['count_untranslated'] = BaseFieldDefinition::create('integer')
->setLabel(t('Untranslated count'))
->setSetting('unsigned', TRUE);
$fields['count_translated'] = BaseFieldDefinition::create('integer')
->setLabel(t('Translated count'))
->setSetting('unsigned', TRUE);
$fields['count_completed'] = BaseFieldDefinition::create('integer')
->setLabel(t('Accepted count'))
->setSetting('unsigned', TRUE);
$fields['word_count'] = BaseFieldDefinition::create('integer')
->setLabel(t('Word count'))
->setSetting('unsigned', TRUE);
return $fields;
}