3 namespace Drupal\content_translation;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Form\FormStateInterface;
9 * Interface for providing content translation.
11 * Defines a set of methods to allow any entity to be processed by the entity
14 interface ContentTranslationHandlerInterface {
17 * Returns a set of field definitions to be used to store metadata items.
19 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
21 public function getFieldDefinitions();
24 * Checks if the user can perform the given operation on translations of the
27 * @param \Drupal\Core\Entity\EntityInterface $entity
28 * The entity whose translation has to be accessed.
30 * The operation to be performed on the translation. Possible values are:
35 * @return \Drupal\Core\Access\AccessResultInterface
38 public function getTranslationAccess(EntityInterface $entity, $op);
41 * Retrieves the source language for the translation being created.
43 * @param \Drupal\Core\Form\FormStateInterface $form_state
44 * The current state of the form.
47 * The source language code.
49 public function getSourceLangcode(FormStateInterface $form_state);
52 * Marks translations as outdated.
54 * @param \Drupal\Core\Entity\EntityInterface $entity
55 * The entity being translated.
56 * @param string $langcode
57 * (optional) The language code of the updated language: all the other
58 * translations will be marked as outdated. Defaults to the entity language.
60 public function retranslate(EntityInterface $entity, $langcode = NULL);
63 * Performs the needed alterations to the entity form.
66 * The entity form to be altered to provide the translation workflow.
67 * @param \Drupal\Core\Form\FormStateInterface $form_state
68 * The current state of the form.
69 * @param \Drupal\Core\Entity\EntityInterface $entity
70 * The entity being created or edited.
72 public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity);