class LayoutBuilderAccessCheck

Same name in other branches
  1. 8.9.x core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php \Drupal\layout_builder\Access\LayoutBuilderAccessCheck
  2. 10 core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php \Drupal\layout_builder\Access\LayoutBuilderAccessCheck
  3. 11.x core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php \Drupal\layout_builder\Access\LayoutBuilderAccessCheck

Provides an access check for the Layout Builder defaults.

@internal Tagged services are internal.

Hierarchy

Expanded class hierarchy of LayoutBuilderAccessCheck

Related topics

1 string reference to 'LayoutBuilderAccessCheck'
layout_builder.services.yml in core/modules/layout_builder/layout_builder.services.yml
core/modules/layout_builder/layout_builder.services.yml
1 service uses LayoutBuilderAccessCheck
access_check.entity.layout_builder_access in core/modules/layout_builder/layout_builder.services.yml
Drupal\layout_builder\Access\LayoutBuilderAccessCheck

File

core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php, line 20

Namespace

Drupal\layout_builder\Access
View source
class LayoutBuilderAccessCheck implements AccessInterface {
    
    /**
     * Checks routing access to the layout.
     *
     * @param \Drupal\layout_builder\SectionStorageInterface $section_storage
     *   The section storage.
     * @param \Drupal\Core\Session\AccountInterface $account
     *   The current user.
     * @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, AccountInterface $account, Route $route) {
        $operation = $route->getRequirement('_layout_builder_access');
        $access = $section_storage->access($operation, $account, TRUE);
        // Check for the global permission unless the section storage checks
        // permissions itself.
        if (!$section_storage->getPluginDefinition()
            ->get('handles_permission_check')) {
            $access = $access->andIf(AccessResult::allowedIfHasPermission($account, 'configure any layout'));
        }
        if ($access instanceof RefinableCacheableDependencyInterface) {
            $access->addCacheableDependency($section_storage);
        }
        return $access;
    }

}

Members

Title Sort descending Modifiers Object type Summary
LayoutBuilderAccessCheck::access public function Checks routing access to the layout.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.