Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\content_translation;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Entity\ContentEntityInterface;
|
Chris@14
|
6 use Drupal\Core\Field\FieldDefinitionInterface;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Provides field translation synchronization capabilities.
|
Chris@0
|
10 */
|
Chris@0
|
11 interface FieldTranslationSynchronizerInterface {
|
Chris@0
|
12
|
Chris@0
|
13 /**
|
Chris@0
|
14 * Performs field column synchronization on the given entity.
|
Chris@0
|
15 *
|
Chris@0
|
16 * Field column synchronization takes care of propagating any change in the
|
Chris@0
|
17 * field items order and in the column values themselves to all the available
|
Chris@0
|
18 * translations. This functionality is provided by defining a
|
Chris@0
|
19 * 'translation_sync' key for the 'content_translation' module's portion of
|
Chris@0
|
20 * the field definition's 'third_party_settings', holding an array of
|
Chris@0
|
21 * column names to be synchronized. The synchronized column values are shared
|
Chris@0
|
22 * across translations, while the rest varies per-language. This is useful for
|
Chris@0
|
23 * instance to translate the "alt" and "title" textual elements of an image
|
Chris@0
|
24 * field, while keeping the same image on every translation.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
|
Chris@0
|
27 * The entity whose values should be synchronized.
|
Chris@0
|
28 * @param string $sync_langcode
|
Chris@0
|
29 * The language of the translation whose values should be used as source for
|
Chris@0
|
30 * synchronization.
|
Chris@0
|
31 * @param string $original_langcode
|
Chris@0
|
32 * (optional) If a new translation is being created, this should be the
|
Chris@0
|
33 * language code of the original values. Defaults to NULL.
|
Chris@0
|
34 */
|
Chris@0
|
35 public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode, $original_langcode = NULL);
|
Chris@0
|
36
|
Chris@0
|
37 /**
|
Chris@0
|
38 * Synchronize the items of a single field.
|
Chris@0
|
39 *
|
Chris@0
|
40 * All the column values of the "active" language are compared to the
|
Chris@0
|
41 * unchanged values to detect any addition, removal or change in the items
|
Chris@0
|
42 * order. Subsequently the detected changes are performed on the field items
|
Chris@0
|
43 * in other available languages.
|
Chris@0
|
44 *
|
Chris@0
|
45 * @param array $field_values
|
Chris@0
|
46 * The field values to be synchronized.
|
Chris@0
|
47 * @param array $unchanged_items
|
Chris@0
|
48 * The unchanged items to be used to detect changes.
|
Chris@0
|
49 * @param string $sync_langcode
|
Chris@0
|
50 * The language code of the items to use as source values.
|
Chris@0
|
51 * @param array $translations
|
Chris@0
|
52 * An array of all the available language codes for the given field.
|
Chris@17
|
53 * @param array $properties
|
Chris@17
|
54 * An array of property names to be synchronized.
|
Chris@0
|
55 */
|
Chris@17
|
56 public function synchronizeItems(array &$field_values, array $unchanged_items, $sync_langcode, array $translations, array $properties);
|
Chris@0
|
57
|
Chris@14
|
58 /**
|
Chris@14
|
59 * Returns the synchronized properties for the specified field definition.
|
Chris@14
|
60 *
|
Chris@14
|
61 * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
|
Chris@14
|
62 * A field definition.
|
Chris@14
|
63 *
|
Chris@14
|
64 * @return string[]
|
Chris@14
|
65 * An array of synchronized field property names.
|
Chris@14
|
66 */
|
Chris@14
|
67 public function getFieldSynchronizedProperties(FieldDefinitionInterface $field_definition);
|
Chris@14
|
68
|
Chris@0
|
69 }
|