public static function Mentions::baseFieldDefinitions in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.2 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.3 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.4 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.5 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.6 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.7 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 8.8 modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 10.3.x modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 10.0.x modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 10.1.x modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
- 10.2.x modules/custom/mentions/src/Entity/Mentions.php \Drupal\mentions\Entity\Mentions::baseFieldDefinitions()
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
- modules/
custom/ mentions/ src/ Entity/ Mentions.php, line 40
Class
- Mentions
- Mentions Class.
Namespace
Drupal\mentions\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['mid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Mention ID'))
->setDescription(t('The primary identifier for a mention.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['entity_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Entity ID'))
->setDescription(t('Entity ID'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('internal uuid'))
->setDescription(t('internal uuid'))
->setReadOnly(TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('UUID'))
->setDescription(t('Mention UUID.'))
->setSetting('target_type', 'user')
->setReadOnly(TRUE);
$fields['auid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('User ID'))
->setDescription(t('The author ID of the mention'))
->setSetting('target_type', 'user')
->setDefaultValue(0);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the mention was created.'));
$fields['entity_type'] = BaseFieldDefinition::create('string')
->setLabel(t('Entity type'))
->setDescription(t('The entity type to which this mention is attached.'))
->setSetting('max_length', 32);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The user language code.'))
->setTranslatable(TRUE);
return $fields;
}