public function ConfigTranslationOverviewAccess::access in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 currently logged in account.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
1 call to ConfigTranslationOverviewAccess::access()
- ConfigTranslationFormAccess::access in core/
modules/ config_translation/ src/ Access/ ConfigTranslationFormAccess.php - Checks access to the overview based on permissions and translatability.
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 67 - Contains \Drupal\config_translation\Access\ConfigTranslationOverviewAccess.
Class
- ConfigTranslationOverviewAccess
- Checks access for displaying the configuration translation overview.
Namespace
Drupal\config_translation\AccessCode
public function access(RouteMatchInterface $route_match, AccountInterface $account) {
$route = $route_match
->getRouteObject();
/** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
$mapper = $this->configMapperManager
->createInstance($route
->getDefault('plugin_id'));
$mapper
->populateFromRouteMatch($route_match);
$this->sourceLanguage = $this->languageManager
->getLanguage($mapper
->getLangcode());
// Allow access to the translation overview if the proper permission is
// granted, the configuration has translatable pieces, and the source
// language is not locked if it is present.
$source_language_access = is_null($this->sourceLanguage) || !$this->sourceLanguage
->isLocked();
$access = $account
->hasPermission('translate configuration') && $mapper
->hasSchema() && $mapper
->hasTranslatable() && $source_language_access;
return AccessResult::allowedIf($access)
->cachePerPermissions();
}