public static function EntityStatus::baseFieldDefinitions in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::baseFieldDefinitions()
- 2.0.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::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
- src/
Entity/ EntityStatus.php, line 1102
Class
- EntityStatus
- Defines the "Content Sync - Entity Status" entity type.
Namespace
Drupal\cms_content_sync\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['flow'] = BaseFieldDefinition::create('string')
->setLabel(t('Flow'))
->setDescription(t('The flow the status entity is based on.'));
$fields['pool'] = BaseFieldDefinition::create('string')
->setLabel(t('Pool'))
->setDescription(t('The pool the entity is connected to.'));
$fields['entity_uuid'] = BaseFieldDefinition::create('string')
->setLabel(t('Entity UUID'))
->setDescription(t('The UUID of the entity that is synchronized.'))
->setSetting('max_length', 128);
$fields['entity_type'] = BaseFieldDefinition::create('string')
->setLabel(t('Entity type'))
->setDescription(t('The entity type of the entity that is synchronized.'));
$fields['entity_type_version'] = BaseFieldDefinition::create('string')
->setLabel(t('Entity type version'))
->setDescription(t('The version of the entity type provided by Content Sync.'))
->setSetting('max_length', 32);
$fields['source_url'] = BaseFieldDefinition::create('string')
->setLabel(t('Source URL'))
->setDescription(t('The entities source URL.'))
->setRequired(false);
$fields['last_export'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Last pushed'))
->setDescription(t('The last time the entity got pushed.'))
->setRequired(false);
$fields['last_import'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Last pulled'))
->setDescription(t('The last time the entity got pulled.'))
->setRequired(false);
$fields['flags'] = BaseFieldDefinition::create('integer')
->setLabel(t('Flags'))
->setDescription(t('Stores boolean information about the pushed/pulled entity.'))
->setSetting('unsigned', true)
->setDefaultValue(0);
$fields['data'] = BaseFieldDefinition::create('map')
->setLabel(t('Data'))
->setDescription(t('Stores further information about the pushed/pulled entity that can also be used by entity and field handlers.'))
->setRequired(false);
return $fields;
}