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