public ContentTranslationHandler::getFieldDefinitions()
Returns a set of field definitions to be used to store metadata items.
Return value
\Drupal\Core\Field\FieldDefinitionInterface[]
Overrides ContentTranslationHandlerInterface::getFieldDefinitions
File
- core/modules/content_translation/src/ContentTranslationHandler.php, line 110
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translation
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | public function getFieldDefinitions() { $definitions = array (); $definitions [ 'content_translation_source' ] = BaseFieldDefinition::create( 'language' ) ->setLabel(t( 'Translation source' )) ->setDescription(t( 'The source language from which this translation was created.' )) ->setDefaultValue(LanguageInterface::LANGCODE_NOT_SPECIFIED) ->setRevisionable(TRUE) ->setTranslatable(TRUE); $definitions [ 'content_translation_outdated' ] = BaseFieldDefinition::create( 'boolean' ) ->setLabel(t( 'Translation outdated' )) ->setDescription(t( 'A boolean indicating whether this translation needs to be updated.' )) ->setDefaultValue(FALSE) ->setRevisionable(TRUE) ->setTranslatable(TRUE); if (! $this ->hasAuthor()) { $definitions [ 'content_translation_uid' ] = BaseFieldDefinition::create( 'entity_reference' ) ->setLabel(t( 'Translation author' )) ->setDescription(t( 'The author of this translation.' )) ->setSetting( 'target_type' , 'user' ) ->setSetting( 'handler' , 'default' ) ->setRevisionable(TRUE) ->setDefaultValueCallback(get_class( $this ) . '::getDefaultOwnerId' ) ->setTranslatable(TRUE); } if (! $this ->hasPublishedStatus()) { $definitions [ 'content_translation_status' ] = BaseFieldDefinition::create( 'boolean' ) ->setLabel(t( 'Translation status' )) ->setDescription(t( 'A boolean indicating whether the translation is visible to non-translators.' )) ->setDefaultValue(TRUE) ->setRevisionable(TRUE) ->setTranslatable(TRUE); } if (! $this ->hasCreatedTime()) { $definitions [ 'content_translation_created' ] = BaseFieldDefinition::create( 'created' ) ->setLabel(t( 'Translation created time' )) ->setDescription(t( 'The Unix timestamp when the translation was created.' )) ->setRevisionable(TRUE) ->setTranslatable(TRUE); } if (! $this ->hasChangedTime()) { $definitions [ 'content_translation_changed' ] = BaseFieldDefinition::create( 'changed' ) ->setLabel(t( 'Translation changed time' )) ->setDescription(t( 'The Unix timestamp when the translation was most recently saved.' )) ->setRevisionable(TRUE) ->setTranslatable(TRUE); } return $definitions ; } |
Please login to continue.