You are here

private function MergeTranslationsForm::mergeTranslations in Merge translations 8

MergeTranslations.

Parameters

\Drupal\node\NodeInterface $node_source: Node source.

string $langcode: Langcode.

1 call to MergeTranslationsForm::mergeTranslations()
MergeTranslationsForm::submitForm in src/Form/MergeTranslationsForm.php
SubmitForm.

File

src/Form/MergeTranslationsForm.php, line 324

Class

MergeTranslationsForm
The merge translation form.

Namespace

Drupal\merge_translations\Form

Code

private function mergeTranslations(NodeInterface $node_source, $langcode) {
  $languages = $this->languages
    ->getLanguages();
  if ($langcode != self::LANGCODE_AUTO) {
    $this
      ->addTranslation($langcode, $node_source
      ->toArray());
  }
  else {
    foreach ($languages as $key => $language) {
      if ($node_source
        ->hasTranslation($key)) {
        $this
          ->addTranslation($key, $node_source
          ->getTranslation($key)
          ->toArray());
      }
    }
  }
}