diff --git a/config_translation.module b/config_translation.module index 6b75adf..8e97209 100644 --- a/config_translation.module +++ b/config_translation.module @@ -86,39 +86,6 @@ function config_translation_menu() { } /** - * Menu item access callback for configuration name based screens. - * - * @param \Drupal\config_translation\ConfigMapperInterface $mapper - * Configuration mapper. - * @param mixed $path_arg - * Path argument from the menu system (entity id or loaded entity for - * configuration entities, NULL otherwise). - * @param \Drupal\Core\Language\Language $language - * (optional) A language object. - * - * @return bool - * TRUE if the current user has access to the group. - */ -function config_translation_config_name_access(ConfigMapperInterface $mapper, $path_arg, $language = NULL) { - // Get configuration group for this mapper. - $group = $mapper->getConfigGroup($path_arg); - $group_language = language_load($group->getLangcode()); - - // Only allow access to translate configuration, if proper permissions are - // granted, the configuration has translatable pieces, the source language - // and target language are not locked, and the target language is not the - // original submission language. Although technically config can be overlayed - // with translations in the same language, that is logically not a good idea. - return ( - user_access('translate configuration') && - $group->hasSchema() && - $group->hasTranslatable() && - !$group_language->locked && - (empty($language) || (!$language->locked && $language->langcode != $group_language->langcode)) - ); -} - -/** * Implements hook_permission(). */ function config_translation_permission() { diff --git a/lib/Drupal/config_translation/Access/ConfigNameCheck.php b/lib/Drupal/config_translation/Access/ConfigNameCheck.php index 3d8d7fd..78d18c9 100644 --- a/lib/Drupal/config_translation/Access/ConfigNameCheck.php +++ b/lib/Drupal/config_translation/Access/ConfigNameCheck.php @@ -31,10 +31,12 @@ class ConfigNameCheck implements AccessCheckInterface { $entity = $request->attributes->get($mapper->getType()); // Get configuration group for this mapper. $group = $mapper->getConfigGroup($entity); + $group_language = language_load($group->getLangcode()); $langcode = $request->attributes->get('langcode'); + $language = NULL; if ($langcode) { - $group_language = language_load($langcode); + $language = language_load($langcode); } // Only allow access to translate configuration, if proper permissions are