You are here

public function ConfigTranslationFormAccess::access in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php \Drupal\config_translation\Access\ConfigTranslationFormAccess::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.

string $langcode: The language code of the target language.

Return value

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

Overrides ConfigTranslationOverviewAccess::access

File

core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php, line 29

Class

ConfigTranslationFormAccess
Checks access for displaying the translation add, edit, and delete forms.

Namespace

Drupal\config_translation\Access

Code

public function access(RouteMatchInterface $route_match, AccountInterface $account, $langcode = NULL) {
  $mapper = $this
    ->getMapperFromRouteMatch($route_match);
  try {
    $source_langcode = $mapper
      ->getLangcode();
    $source_language = $this->languageManager
      ->getLanguage($source_langcode);
    $target_language = $this->languageManager
      ->getLanguage($langcode);
    return $this
      ->doCheckAccess($account, $mapper, $source_language, $target_language);
  } catch (ConfigMapperLanguageException $exception) {
    return AccessResult::forbidden();
  }
}