protected function MetatagViewsTranslationForm::prepareValues in Metatag 8
Gets the translated values while storing a copy of the original values.
1 call to MetatagViewsTranslationForm::prepareValues()
- MetatagViewsTranslationForm::buildForm in metatag_views/
src/ Form/ MetatagViewsTranslationForm.php - Form constructor.
File
- metatag_views/
src/ Form/ MetatagViewsTranslationForm.php, line 137
Class
- MetatagViewsTranslationForm
- Defines a form for translating meta tags for views.
Namespace
Drupal\metatag_views\FormCode
protected function prepareValues() {
$config_name = $this->view
->getConfigDependencyName();
$config_path = 'display.' . $this->displayId . '.display_options.display_extenders.metatag_display_extender.metatags';
$configuration = $this
->configFactory()
->get($config_name);
$this->baseData = $configuration
->getOriginal($config_path, FALSE);
// Set the translation target language on the configuration factory.
$original_language = $this->languageManager
->getConfigOverrideLanguage();
$this->languageManager
->setConfigOverrideLanguage($this->language);
// Read in translated values.
$configuration = $this
->configFactory()
->get($config_name);
$translated_values = $configuration
->get($config_path);
// Set the configuration language back.
$this->languageManager
->setConfigOverrideLanguage($original_language);
return $translated_values;
}