public function ConfigTranslationFormAccess::access in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 currently logged in account.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides ConfigTranslationOverviewAccess::access
File
- core/
modules/ config_translation/ src/ Access/ ConfigTranslationFormAccess.php, line 22 - Contains \Drupal\config_translation\Access\ConfigTranslationFormAccess.
Class
- ConfigTranslationFormAccess
- Checks access for displaying the translation add, edit, and delete forms.
Namespace
Drupal\config_translation\AccessCode
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_match, $account);
if ($base_access
->isAllowed()) {
$target_language = $this->languageManager
->getLanguage($langcode);
// Make sure that the target language is not locked, and that the target
// language is not the original submission language. Although technically
// configuration can be overlaid with translations in the same language,
// that is logically not a good idea.
$access = !empty($target_language) && !$target_language
->isLocked() && (empty($this->sourceLanguage) || $target_language
->getId() != $this->sourceLanguage
->getId());
return $base_access
->andIf(AccessResult::allowedIf($access));
}
return $base_access;
}