function ContentTranslationHandler::getFieldDefinitions
Returns a set of field definitions to be used to store metadata items.
Return value
\Drupal\Core\Field\FieldDefinitionInterface[] The field definitions.
Overrides ContentTranslationHandlerInterface::getFieldDefinitions
File
- 
              core/
modules/ content_translation/ src/ ContentTranslationHandler.php, line 118  
Class
- ContentTranslationHandler
 - Base class for content translation handlers.
 
Namespace
Drupal\content_translationCode
public function getFieldDefinitions() {
  $definitions = [];
  $definitions['content_translation_source'] = BaseFieldDefinition::create('language')->setLabel($this->t('Translation source'))
    ->setDescription($this->t('The source language from which this translation was created.'))
    ->setDefaultValue(LanguageInterface::LANGCODE_NOT_SPECIFIED)
    ->setInitialValue(LanguageInterface::LANGCODE_NOT_SPECIFIED)
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE);
  $definitions['content_translation_outdated'] = BaseFieldDefinition::create('boolean')->setLabel($this->t('Translation outdated'))
    ->setDescription($this->t('A boolean indicating whether this translation needs to be updated.'))
    ->setDefaultValue(FALSE)
    ->setInitialValue(FALSE)
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE);
  if (!$this->hasAuthor()) {
    $definitions['content_translation_uid'] = BaseFieldDefinition::create('entity_reference')->setLabel($this->t('Translation author'))
      ->setDescription($this->t('The author of this translation.'))
      ->setSetting('target_type', 'user')
      ->setSetting('handler', 'default')
      ->setRevisionable(TRUE)
      ->setDefaultValueCallback(static::class . '::getDefaultOwnerId')
      ->setTranslatable(TRUE);
  }
  if (!$this->hasPublishedStatus()) {
    $definitions['content_translation_status'] = BaseFieldDefinition::create('boolean')->setLabel($this->t('Translation status'))
      ->setDescription($this->t('A boolean indicating whether the translation is visible to non-translators.'))
      ->setDefaultValue(TRUE)
      ->setInitialValue(TRUE)
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE);
  }
  if (!$this->hasCreatedTime()) {
    $definitions['content_translation_created'] = BaseFieldDefinition::create('created')->setLabel($this->t('Translation created time'))
      ->setDescription($this->t('The Unix timestamp when the translation was created.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE);
  }
  if (!$this->hasChangedTime()) {
    $definitions['content_translation_changed'] = BaseFieldDefinition::create('changed')->setLabel($this->t('Translation changed time'))
      ->setDescription($this->t('The Unix timestamp when the translation was most recently saved.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE);
  }
  return $definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.