You are here

public function WebformTranslationManager::getOriginalLangcode in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformTranslationManager.php \Drupal\webform\WebformTranslationManager::getOriginalLangcode()

Get the original langcode for a webform.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

string The original langcode for a webform.

Overrides WebformTranslationManagerInterface::getOriginalLangcode

2 calls to WebformTranslationManager::getOriginalLangcode()
WebformTranslationManager::getBaseElements in src/WebformTranslationManager.php
Get base webform elements for the site's default language.
WebformTranslationManager::getElements in src/WebformTranslationManager.php
Get webform elements for specific language.

File

src/WebformTranslationManager.php, line 191

Class

WebformTranslationManager
Defines a class to translate webform elements.

Namespace

Drupal\webform

Code

public function getOriginalLangcode(WebformInterface $webform) {

  // NOTE: Can't inject ConfigMapperInterface because it requires that
  // config_translation.module to be installed.

  /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
  $mapper = \Drupal::service('plugin.manager.config_translation.mapper')
    ->createInstance('webform');
  $mapper
    ->addConfigName('webform.webform.' . $webform
    ->id());
  return $mapper
    ->getLangcode();
}