function LayoutPreviewAccessAllowed::access

Same name in other branches
  1. 9 core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php \Drupal\layout_builder\Access\LayoutPreviewAccessAllowed::access()
  2. 8.9.x core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php \Drupal\layout_builder\Access\LayoutPreviewAccessAllowed::access()
  3. 11.x core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php \Drupal\layout_builder\Access\LayoutPreviewAccessAllowed::access()

Overrides AccessibleInterface::access

File

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

Class

LayoutPreviewAccessAllowed
Accessible class to allow access for inline blocks in the Layout Builder.

Namespace

Drupal\layout_builder\Access

Code

public function access($operation, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
    if ($operation === 'view') {
        return $return_as_object ? AccessResult::allowed() : TRUE;
    }
    // The layout builder preview should only need 'view' access.
    return $return_as_object ? AccessResult::forbidden() : FALSE;
}

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