Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\content_translation;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Entity\EntityInterface;
|
Chris@0
|
6 use Drupal\Core\Form\FormStateInterface;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Interface for providing content translation.
|
Chris@0
|
10 *
|
Chris@0
|
11 * Defines a set of methods to allow any entity to be processed by the entity
|
Chris@0
|
12 * translation UI.
|
Chris@0
|
13 */
|
Chris@0
|
14 interface ContentTranslationHandlerInterface {
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * Returns a set of field definitions to be used to store metadata items.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
|
Chris@0
|
20 */
|
Chris@0
|
21 public function getFieldDefinitions();
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Checks if the user can perform the given operation on translations of the
|
Chris@0
|
25 * wrapped entity.
|
Chris@0
|
26 *
|
Chris@0
|
27 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
28 * The entity whose translation has to be accessed.
|
Chris@0
|
29 * @param $op
|
Chris@0
|
30 * The operation to be performed on the translation. Possible values are:
|
Chris@0
|
31 * - "create"
|
Chris@0
|
32 * - "update"
|
Chris@0
|
33 * - "delete"
|
Chris@0
|
34 *
|
Chris@0
|
35 * @return \Drupal\Core\Access\AccessResultInterface
|
Chris@0
|
36 * The access result.
|
Chris@0
|
37 */
|
Chris@0
|
38 public function getTranslationAccess(EntityInterface $entity, $op);
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Retrieves the source language for the translation being created.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @param \Drupal\Core\Form\FormStateInterface $form_state
|
Chris@0
|
44 * The current state of the form.
|
Chris@0
|
45 *
|
Chris@0
|
46 * @return string
|
Chris@0
|
47 * The source language code.
|
Chris@0
|
48 */
|
Chris@0
|
49 public function getSourceLangcode(FormStateInterface $form_state);
|
Chris@0
|
50
|
Chris@0
|
51 /**
|
Chris@0
|
52 * Marks translations as outdated.
|
Chris@0
|
53 *
|
Chris@0
|
54 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
55 * The entity being translated.
|
Chris@0
|
56 * @param string $langcode
|
Chris@0
|
57 * (optional) The language code of the updated language: all the other
|
Chris@0
|
58 * translations will be marked as outdated. Defaults to the entity language.
|
Chris@0
|
59 */
|
Chris@0
|
60 public function retranslate(EntityInterface $entity, $langcode = NULL);
|
Chris@0
|
61
|
Chris@0
|
62 /**
|
Chris@0
|
63 * Performs the needed alterations to the entity form.
|
Chris@0
|
64 *
|
Chris@0
|
65 * @param array $form
|
Chris@0
|
66 * The entity form to be altered to provide the translation workflow.
|
Chris@0
|
67 * @param \Drupal\Core\Form\FormStateInterface $form_state
|
Chris@0
|
68 * The current state of the form.
|
Chris@0
|
69 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
70 * The entity being created or edited.
|
Chris@0
|
71 */
|
Chris@0
|
72 public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity);
|
Chris@0
|
73
|
Chris@0
|
74 }
|