getMapperFromRouteMatch example


  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);

    

  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();
    }
Home | Imprint | This part of the site doesn't use cookies.