diff --git a/core/modules/config_translation/src/ConfigMapperInterface.php b/core/modules/config_translation/src/ConfigMapperInterface.php index 72d2112..8926d30 100644 --- a/core/modules/config_translation/src/ConfigMapperInterface.php +++ b/core/modules/config_translation/src/ConfigMapperInterface.php @@ -206,6 +206,16 @@ public function getConfigData(); public function getLangcode(); /** + * Sets the original language code. + * + * @param string $langcode + * The langcode. + * + * @return $this + */ + public function setLangcode($langcode); + + /** * Returns language object for the configuration. * * If the language of the configuration files is not a configured language on diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index af3ba94..7d9afaa 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -405,6 +405,15 @@ public function getLangcode() { /** * {@inheritdoc} */ + public function setLangcode($langcode) { + $this->langcode = $langcode; + return $this; + } + + + /** + * {@inheritdoc} + */ public function getLanguageWithFallback() { $langcode = $this->getLangcode(); $language = $this->languageManager->getLanguage($langcode); diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index bac2b24..e9c396d 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -13,6 +13,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\PathProcessor\InboundPathProcessorInterface; +use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; @@ -122,7 +123,7 @@ public static function create(ContainerInterface $container) { public function itemPage(Request $request, RouteMatchInterface $route_match, $plugin_id) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($plugin_id); - $mapper->populateFromRouteMatch($request); + $mapper->populateFromRouteMatch($route_match); $page = array(); $page['#title'] = $this->t('Translations for %label', array('%label' => $mapper->getTitle())); @@ -158,8 +159,9 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // This is needed because // ConfigMapperInterface::getAddRouteParameters(), for example, // needs to return the correct language code for each table row. - $fake_request->attributes->set('langcode', $langcode); - $mapper->populateFromRouteMatch($fake_request); + $fake_route_match = RouteMatch::createFromRequest($fake_request); + $mapper->populateFromRouteMatch($fake_route_match); + $mapper->setLangcode($langcode); // Prepare the language name and the operations depending on whether this // is the original language or not. diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index d3cc6da..eb32499 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -12,6 +12,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -116,10 +117,10 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($plugin_id); - $mapper->populateFromRouteMatch($request); + $mapper->populateFromRouteMatch($route_match); $language = $this->languageManager->getLanguage($langcode); if (!$language) { diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index 5303376..372635a 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -9,6 +9,7 @@ use Drupal\config_translation\ConfigMapperManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\TraversableTypedDataInterface; use Drupal\Core\Form\BaseFormIdInterface; @@ -132,10 +133,10 @@ public function getBaseFormId() { * Throws an exception if the language code provided as a query parameter in * the request does not match an active language. */ - public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($plugin_id); - $mapper->populateFromRouteMatch($request); + $mapper->populateFromRouteMatch($route_match); $language = $this->languageManager->getLanguage($langcode); if (!$language) {