You are here

public function ConfigTranslationOverviewAccess::access in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php \Drupal\config_translation\Access\ConfigTranslationOverviewAccess::access()

Checks access to the overview based on permissions and translatability.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route_match to check against.

\Drupal\Core\Session\AccountInterface $account: The account to check access for.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 method overrides ConfigTranslationOverviewAccess::access()
ConfigTranslationFormAccess::access in core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php
Checks access to the overview based on permissions and translatability.

File

core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php, line 57

Class

ConfigTranslationOverviewAccess
Checks access for displaying the configuration translation overview.

Namespace

Drupal\config_translation\Access

Code

public function access(RouteMatchInterface $route_match, AccountInterface $account) {
  $mapper = $this
    ->getMapperFromRouteMatch($route_match);
  try {
    $langcode = $mapper
      ->getLangcode();
  } catch (ConfigMapperLanguageException $exception) {

    // ConfigTranslationController shows a helpful message if the language
    // codes do not match, so do not let that prevent granting access.
    $langcode = 'en';
  }
  $source_language = $this->languageManager
    ->getLanguage($langcode);
  return $this
    ->doCheckAccess($account, $mapper, $source_language);
}