function LayoutSectionAccessCheck::access

Checks routing access to the layout.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

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

File

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

Class

LayoutSectionAccessCheck
Provides an access check for the Layout Builder UI.

Namespace

Drupal\layout_builder\Access

Code

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);
}

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