annotate core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
rev   line source
Chris@4 1 <?php
Chris@4 2
Chris@4 3 namespace Drupal\layout_builder\Access;
Chris@4 4
Chris@4 5 use Drupal\Core\Access\AccessibleInterface;
Chris@4 6 use Drupal\Core\Access\AccessResult;
Chris@4 7 use Drupal\Core\Session\AccountInterface;
Chris@4 8
Chris@4 9 /**
Chris@4 10 * Accessible class to allow access for inline blocks in the Layout Builder.
Chris@4 11 *
Chris@4 12 * @internal
Chris@5 13 * Tagged services are internal.
Chris@4 14 */
Chris@4 15 class LayoutPreviewAccessAllowed implements AccessibleInterface {
Chris@4 16
Chris@4 17 /**
Chris@4 18 * {@inheritdoc}
Chris@4 19 */
Chris@4 20 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
Chris@4 21 if ($operation === 'view') {
Chris@4 22 return $return_as_object ? AccessResult::allowed() : TRUE;
Chris@4 23 }
Chris@4 24 // The layout builder preview should only need 'view' access.
Chris@4 25 return $return_as_object ? AccessResult::forbidden() : FALSE;
Chris@4 26 }
Chris@4 27
Chris@4 28 }