You are here

protected function ConfigTranslationFormAccess::doCheckAccess in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php \Drupal\config_translation\Access\ConfigTranslationFormAccess::doCheckAccess()
  2. 9 core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php \Drupal\config_translation\Access\ConfigTranslationFormAccess::doCheckAccess()

Checks access given an account, configuration mapper, and source language.

In addition to the checks performed by ConfigTranslationOverviewAccess::doCheckAccess() this makes sure the target language is not locked and the target language is not the source language.

Although technically configuration can be overlaid with translations in the same language, that is logically not a good idea.

Parameters

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

\Drupal\config_translation\ConfigMapperInterface $mapper: The configuration mapper to check access for.

\Drupal\Core\Language\LanguageInterface|null $source_language: The source language to check for, if any.

\Drupal\Core\Language\LanguageInterface|null $target_language: The target language to check for, if any.

Return value

\Drupal\Core\Access\AccessResultInterface The result of the access check.

Overrides ConfigTranslationOverviewAccess::doCheckAccess

See also

\Drupal\config_translation\Access\ConfigTranslationOverviewAccess::doCheckAccess()

1 call to ConfigTranslationFormAccess::doCheckAccess()
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/ConfigTranslationFormAccess.php, line 69

Class

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

Namespace

Drupal\config_translation\Access

Code

protected function doCheckAccess(AccountInterface $account, ConfigMapperInterface $mapper, $source_language = NULL, $target_language = NULL) {
  $base_access_result = parent::doCheckAccess($account, $mapper, $source_language);
  $access = $target_language && !$target_language
    ->isLocked() && (!$source_language || $target_language
    ->getId() !== $source_language
    ->getId());
  return $base_access_result
    ->andIf(AccessResult::allowedIf($access));
}