annotate core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents
children 12f9dff5fda9
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@4 13 */
Chris@4 14 class LayoutPreviewAccessAllowed implements AccessibleInterface {
Chris@4 15
Chris@4 16 /**
Chris@4 17 * {@inheritdoc}
Chris@4 18 */
Chris@4 19 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
Chris@4 20 if ($operation === 'view') {
Chris@4 21 return $return_as_object ? AccessResult::allowed() : TRUE;
Chris@4 22 }
Chris@4 23 // The layout builder preview should only need 'view' access.
Chris@4 24 return $return_as_object ? AccessResult::forbidden() : FALSE;
Chris@4 25 }
Chris@4 26
Chris@4 27 }