You are here

class ConfigTranslationFormAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php \Drupal\config_translation\Access\ConfigTranslationFormAccess

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

Hierarchy

Expanded class hierarchy of ConfigTranslationFormAccess

1 string reference to 'ConfigTranslationFormAccess'
config_translation.services.yml in core/modules/config_translation/config_translation.services.yml
core/modules/config_translation/config_translation.services.yml
1 service uses ConfigTranslationFormAccess
config_translation.access.form in core/modules/config_translation/config_translation.services.yml
Drupal\config_translation\Access\ConfigTranslationFormAccess

File

core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php, line 17
Contains \Drupal\config_translation\Access\ConfigTranslationFormAccess.

Namespace

Drupal\config_translation\Access
View source
class ConfigTranslationFormAccess extends ConfigTranslationOverviewAccess {

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigTranslationFormAccess::access public function Checks access to the overview based on permissions and translatability. Overrides ConfigTranslationOverviewAccess::access
ConfigTranslationOverviewAccess::$configMapperManager protected property The mapper plugin discovery service.
ConfigTranslationOverviewAccess::$languageManager protected property The language manager.
ConfigTranslationOverviewAccess::$sourceLanguage protected property The source language.
ConfigTranslationOverviewAccess::__construct public function Constructs a ConfigTranslationOverviewAccess object.