You are here

public static function ContentModerationState::baseFieldDefinitions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/src/Entity/ContentModerationState.php \Drupal\content_moderation\Entity\ContentModerationState::baseFieldDefinitions()
  2. 9 core/modules/content_moderation/src/Entity/ContentModerationState.php \Drupal\content_moderation\Entity\ContentModerationState::baseFieldDefinitions()

File

core/modules/content_moderation/src/Entity/ContentModerationState.php, line 57

Class

ContentModerationState
Defines the Content moderation state entity.

Namespace

Drupal\content_moderation\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields = parent::baseFieldDefinitions($entity_type);
  $fields += static::ownerBaseFieldDefinitions($entity_type);
  $fields['uid']
    ->setLabel(t('User'))
    ->setDescription(t('The username of the entity creator.'))
    ->setRevisionable(TRUE);
  $fields['workflow'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Workflow'))
    ->setDescription(t('The workflow the moderation state is in.'))
    ->setSetting('target_type', 'workflow')
    ->setRequired(TRUE)
    ->setRevisionable(TRUE);
  $fields['moderation_state'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Moderation state'))
    ->setDescription(t('The moderation state of the referenced content.'))
    ->setRequired(TRUE)
    ->setTranslatable(TRUE)
    ->setRevisionable(TRUE);
  $fields['content_entity_type_id'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Content entity type ID'))
    ->setDescription(t('The ID of the content entity type this moderation state is for.'))
    ->setRequired(TRUE)
    ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH)
    ->setRevisionable(TRUE);
  $fields['content_entity_id'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('Content entity ID'))
    ->setDescription(t('The ID of the content entity this moderation state is for.'))
    ->setRequired(TRUE)
    ->setRevisionable(TRUE);
  $fields['content_entity_revision_id'] = BaseFieldDefinition::create('integer')
    ->setLabel(t('Content entity revision ID'))
    ->setDescription(t('The revision ID of the content entity this moderation state is for.'))
    ->setRequired(TRUE)
    ->setRevisionable(TRUE);
  return $fields;
}