You are here

protected function OverridesSectionStorage::handleTranslationAccess in Layout Builder Symmetric Translations 8

Handles access checks related to translations.

Parameters

\Drupal\Core\Access\AccessResult $result: The access result.

string $operation: The operation to be performed.

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

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

Overrides OverridesSectionStorage::handleTranslationAccess

File

src/Plugin/SectionStorage/OverridesSectionStorage.php, line 24

Class

OverridesSectionStorage

Namespace

Drupal\layout_builder_st\Plugin\SectionStorage

Code

protected function handleTranslationAccess(AccessResult $result, $operation, AccountInterface $account) {
  $entity = $this
    ->getEntity();
  $field_config = $entity
    ->getFieldDefinition(static::FIELD_NAME)
    ->getConfig($entity
    ->bundle());

  // Access is allow if one of the following conditions is true:
  // 1. This is the default translation.
  // 2. The entity is translatable and the layout is overridden and the layout
  //    field is not translatable.
  return $result
    ->andIf(AccessResult::allowedIf($this
    ->isDefaultTranslation() || $entity instanceof TranslatableInterface && $this
    ->isOverridden() && !$field_config
    ->isTranslatable()))
    ->addCacheableDependency($entity)
    ->addCacheableDependency($field_config);
}