interface ContentTranslationHandlerInterface (View source)

Interface for providing content translation.

Defines a set of methods to allow any entity to be processed by the entity translation UI.

Methods

getFieldDefinitions()

Returns a set of field definitions to be used to store metadata items.

getTranslationAccess(EntityInterface $entity, $op)

Checks if the user can perform the given operation on translations of the wrapped entity.

string
getSourceLangcode(FormStateInterface $form_state)

Retrieves the source language for the translation being created.

retranslate(EntityInterface $entity, string $langcode = NULL)

Marks translations as outdated.

entityFormAlter(array $form, FormStateInterface $form_state, EntityInterface $entity)

Performs the needed alterations to the entity form.

Details

FieldDefinitionInterface[] getFieldDefinitions()

Returns a set of field definitions to be used to store metadata items.

Return Value

FieldDefinitionInterface[]

AccessResultInterface getTranslationAccess(EntityInterface $entity, $op)

Checks if the user can perform the given operation on translations of the wrapped entity.

Parameters

EntityInterface $entity

The entity whose translation has to be accessed.

$op

The operation to be performed on the translation. Possible values are:

  • "create"
  • "update"
  • "delete"

Return Value

AccessResultInterface

The access result.

string getSourceLangcode(FormStateInterface $form_state)

Retrieves the source language for the translation being created.

Parameters

FormStateInterface $form_state

The current state of the form.

Return Value

string

The source language code.

retranslate(EntityInterface $entity, string $langcode = NULL)

Marks translations as outdated.

Parameters

EntityInterface $entity

The entity being translated.

string $langcode

(optional) The language code of the updated language: all the other translations will be marked as outdated. Defaults to the entity language.

entityFormAlter(array $form, FormStateInterface $form_state, EntityInterface $entity)

Performs the needed alterations to the entity form.

Parameters

array $form

The entity form to be altered to provide the translation workflow.

FormStateInterface $form_state

The current state of the form.

EntityInterface $entity

The entity being created or edited.