You are here

class LayoutBuilderAccessCheck in Drupal 8

Same name and namespace in other branches
  1. 9 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

Namesort descending Modifiers Type Description Overrides
LayoutBuilderAccessCheck::access public function Checks routing access to the layout.