diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/layout_builder/src/Access/LayoutPreviewAccessAllowed.php	Thu Feb 28 13:11:55 2019 +0000
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\layout_builder\Access;
+
+use Drupal\Core\Access\AccessibleInterface;
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Accessible class to allow access for inline blocks in the Layout Builder.
+ *
+ * @internal
+ */
+class LayoutPreviewAccessAllowed implements AccessibleInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  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;
+  }
+
+}