class LayoutSectionAccessCheck

Provides an access check for the Layout Builder UI.

@internal Tagged services are internal.

@todo Deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\layout_builder\Access\LayoutBuilderAccessCheck instead. See https://www.drupal.org/node/3039551.

Hierarchy

Expanded class hierarchy of LayoutSectionAccessCheck

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

File

core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php, line 21

Namespace

Drupal\layout_builder\Access
View source
class LayoutSectionAccessCheck implements AccessInterface {
    
    /**
     * Checks routing access to the layout.
     *
     * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
     *   The current route match.
     * @param \Drupal\Core\Session\AccountInterface $account
     *   The currently logged in account.
     *
     * @return \Drupal\Core\Access\AccessResultInterface
     *   The access result.
     */
    public function access(RouteMatchInterface $route_match, AccountInterface $account) {
        @trigger_error(__NAMESPACE__ . '\\LayoutSectionAccessCheck is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\layout_builder\\Access\\LayoutBuilderAccessCheck instead. See https://www.drupal.org/node/3039551.', E_USER_DEPRECATED);
        $section_storage = $route_match->getParameter('section_storage');
        if (empty($section_storage)) {
            return AccessResult::forbidden()->addCacheContexts([
                'route',
            ]);
        }
        if (!$section_storage instanceof SectionStorageInterface) {
            $access = AccessResult::forbidden();
        }
        else {
            $access = AccessResult::allowedIfHasPermission($account, 'configure any layout');
        }
        return $access->addCacheableDependency($section_storage);
    }

}

Members

Title Sort descending Modifiers Object type Summary
LayoutSectionAccessCheck::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.