You are here

public function SyncIntent::changeTranslationLanguage in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/SyncIntent.php \Drupal\cms_content_sync\SyncIntent::changeTranslationLanguage()
  2. 2.0.x src/SyncIntent.php \Drupal\cms_content_sync\SyncIntent::changeTranslationLanguage()

Change the language used for provided field values. If you want to add a translation of an entity, the same SyncIntent is used. First, you add your fields using self::setField() for the untranslated version. After that you call self::changeTranslationLanguage() with the language identifier for the translation in question. Then you perform all the self::setField() updates for that language and eventually return to the untranslated entity by using self::changeTranslationLanguage() without arguments.

Parameters

string $language: The identifier of the language to switch to or NULL to reset

File

src/SyncIntent.php, line 284

Class

SyncIntent
Class SyncIntent.

Namespace

Drupal\cms_content_sync

Code

public function changeTranslationLanguage($language = null) {
  $this->activeLanguage = $language;
  if ($this->entity) {
    if ($language) {
      $this->entity = $this->entity
        ->getTranslation($language);
    }
    else {
      $this->entity = $this->entity
        ->getUntranslated();
    }
  }
}