/**
  * Checks access to the overview based on permissions and translatability.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, AccountInterface $account)
 {
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($route->getDefault('plugin_id'));
     $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)->cachePerRole();
 }
 /**
  * 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.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The account to check access for.
  * @param \Drupal\config_translation\ConfigMapperInterface $mapper
  *   The configuration mapper to check access for.
  * @param \Drupal\Core\Language\LanguageInterface|null $source_language
  *   The source language to check for, if any.
  * @param \Drupal\Core\Language\LanguageInterface|null $target_language
  *   The target language to check for, if any.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The result of the access check.
  *
  * @see \Drupal\config_translation\Access\ConfigTranslationOverviewAccess::doCheckAccess()
  */
 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));
 }
 /**
  * Checks access given an account, configuration mapper, and source language.
  *
  * Grants access if the proper permission is granted to the account, the
  * configuration has translatable pieces, and the source language is not
  * locked given it is present.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The account to check access for.
  * @param \Drupal\config_translation\ConfigMapperInterface $mapper
  *   The configuration mapper to check access for.
  * @param \Drupal\Core\Language\LanguageInterface|null $source_language
  *   The source language to check for, if any.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The result of the access check.
  */
 protected function doCheckAccess(AccountInterface $account, ConfigMapperInterface $mapper, $source_language = NULL)
 {
     $access = $account->hasPermission('translate configuration') && $mapper->hasSchema() && $mapper->hasTranslatable() && (!$source_language || !$source_language->isLocked());
     return AccessResult::allowedIf($access)->cachePerPermissions();
 }