You are here

final class LayoutBuilderTranslationAccessCheck in Layout Builder Symmetric Translations 8

Provides an access check for the Layout Builder translations.

@internal Tagged services are internal.

Hierarchy

Expanded class hierarchy of LayoutBuilderTranslationAccessCheck

1 string reference to 'LayoutBuilderTranslationAccessCheck'
layout_builder_st.services.yml in ./layout_builder_st.services.yml
layout_builder_st.services.yml
1 service uses LayoutBuilderTranslationAccessCheck
access_check.entity.layout_builder_translation_access in ./layout_builder_st.services.yml
Drupal\layout_builder_st\Access\LayoutBuilderTranslationAccessCheck

File

src/Access/LayoutBuilderTranslationAccessCheck.php, line 20

Namespace

Drupal\layout_builder_st\Access
View source
final class LayoutBuilderTranslationAccessCheck implements AccessInterface {
  use LayoutEntityHelperTrait;
  use TranslationsHelperTrait;

  /**
   * Checks routing access to the default translation only layout.
   *
   * @param \Drupal\layout_builder\SectionStorageInterface $section_storage
   *   The section storage.
   * @param \Symfony\Component\Routing\Route $route
   *   The route to check against.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(SectionStorageInterface $section_storage, Route $route) {
    $translation_type = $route
      ->getRequirement('_layout_builder_translation_access');
    $is_translation = static::isTranslation($section_storage);
    switch ($translation_type) {
      case 'untranslated':
        $access = AccessResult::allowedIf(!$is_translation);
        break;
      case 'translated':
        $access = AccessResult::allowedIf($is_translation);
        break;
      default:
        throw new \UnexpectedValueException("Unexpected _layout_builder_translation_access route requirement: {$translation_type}");
    }
    return $access;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LayoutBuilderTranslationAccessCheck::access public function Checks routing access to the default translation only layout.
LayoutEntityHelperTrait::$sectionStorageManager protected property The section storage manager. 1
LayoutEntityHelperTrait::getEntitySections protected function Gets the sections for an entity if any.
LayoutEntityHelperTrait::getInlineBlockComponents protected function Gets components that have Inline Block plugins.
LayoutEntityHelperTrait::getInlineBlockRevisionIdsInSections protected function Gets revision IDs for layout sections.
LayoutEntityHelperTrait::getSectionStorageForEntity protected function Gets the section storage for an entity.
LayoutEntityHelperTrait::isEntityUsingFieldOverride Deprecated protected function Determines if an entity is using a field for the layout override.
LayoutEntityHelperTrait::isLayoutCompatibleEntity protected function Determines if an entity can have a layout.
LayoutEntityHelperTrait::originalEntityUsesDefaultStorage protected function Determines if the original entity used the default section storage.
LayoutEntityHelperTrait::sectionStorageManager private function Gets the section storage manager. 1
TranslationsHelperTrait::isTranslation protected static function Determines if the sections is for a translation.