diff --git a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php index d7baae3..af584de 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php @@ -8,8 +8,8 @@ namespace Drupal\config_translation\Access; use Drupal\Core\Access\AccessResult; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; -use Symfony\Component\Routing\Route; /** * Checks access for displaying the translation add, edit, and delete forms. @@ -19,10 +19,10 @@ class ConfigTranslationFormAccess extends ConfigTranslationOverviewAccess { /** * {@inheritdoc} */ - public function access(Route $route, AccountInterface $account, $langcode = NULL) { + public function access(RouteMatchInterface $route_match, AccountInterface $account, $langcode = NULL) { // For the translation forms we have a target language, so we need some // checks in addition to the checks performed for the translation overview. - $base_access = parent::access($route, $account); + $base_access = parent::access($route_match, $account); if ($base_access->isAllowed()) { $target_language = $this->languageManager->getLanguage($langcode); diff --git a/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php index 237e89a..ec588bb 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php @@ -11,8 +11,8 @@ use Drupal\config_translation\ConfigMapperManagerInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Routing\Access\AccessInterface; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; -use Symfony\Component\Routing\Route; /** * Checks access for displaying the configuration translation overview. @@ -54,17 +54,20 @@ public function __construct(ConfigMapperManagerInterface $config_mapper_manager, /** * Checks access to the overview based on permissions and translatability. * - * @param \Symfony\Component\Routing\Route $route - * The route to check against. + * @param \Drupal\Core\Routing\RouteMatchInterface $route_match + * The route_match to check against. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */ - public function access(Route $route, AccountInterface $account) { + public function access(RouteMatchInterface $route_match, AccountInterface $account) { + $route = $route_match->getRouteObject(); + /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($route->getDefault('plugin_id')); + $mapper->populateFromRouteMatch($route_match); $this->sourceLanguage = $this->languageManager->getLanguage($mapper->getLangcode()); // Allow access to the translation overview if the proper permission is diff --git a/core/modules/config_translation/src/ConfigMapperInterface.php b/core/modules/config_translation/src/ConfigMapperInterface.php index 9815f85..90d405a 100644 --- a/core/modules/config_translation/src/ConfigMapperInterface.php +++ b/core/modules/config_translation/src/ConfigMapperInterface.php @@ -253,11 +253,11 @@ public function getTypeLabel(); public function hasSchema(); /** - * Checks that all pieces of this configuration mapper have translatables. + * Checks if pieces of this configuration mapper have translatables. * * @return bool - * TRUE if all of the configuration elements have translatables, FALSE - * otherwise. + * TRUE if at least one of the configuration elements has translatables, + * FALSE otherwise. */ public function hasTranslatable(); diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index 6a51be6..4d98e2a 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -438,11 +438,11 @@ public function hasSchema() { */ public function hasTranslatable() { foreach ($this->getConfigNames() as $name) { - if (!$this->configMapperManager->hasTranslatable($name)) { - return FALSE; + if ($this->configMapperManager->hasTranslatable($name)) { + return TRUE; } } - return TRUE; + return FALSE; } /** diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index a359c9f..c565e8c 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -660,7 +660,7 @@ public function testPluralConfigStringsSourceElements() { $config->save(); // Go to the translation page of the 'files' view. - $translation_url = 'admin/structure/views/view/files/translate/' . $langcode . '/add'; + $translation_url = 'admin/structure/views/view/files/translate/en/add'; $this->drupalGet($translation_url); // Check if the expected number of source elements are present. diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index 9ecc32b..0223c6f 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -538,7 +538,7 @@ public function testHasTranslatable(array $mock_return_values, $expected) { $map = array(); foreach ($config_names as $i => $config_name) { - $map[] = array($config_name, $mock_return_values[$i]); + $map[] = isset($mock_return_values[$i]) ? array($config_name, $mock_return_values[$i]) : array(); } $this->configMapperManager ->expects($this->any()) @@ -560,10 +560,12 @@ public function testHasTranslatable(array $mock_return_values, $expected) { */ public function providerTestHasTranslatable() { return array( + array(array(), FALSE), array(array(TRUE), TRUE), array(array(FALSE), FALSE), array(array(TRUE, TRUE, TRUE), TRUE), - array(array(TRUE, FALSE, TRUE), FALSE), + array(array(FALSE, FALSE, FALSE), FALSE), + array(array(TRUE, FALSE, TRUE), TRUE), ); }