Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphAccessControlHandler.php
index d49c368f9453ba35e44bb947f3c6ef063b55e222..9168590c414e5357e10ffbd793553b24c8a5dab3 100644 (file)
@@ -20,15 +20,18 @@ class ParagraphAccessControlHandler extends EntityAccessControlHandler {
   protected function checkAccess(EntityInterface $paragraph, $operation, AccountInterface $account) {
     // Allowed when the operation is not view or the status is true.
     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
+    $access_result = AccessResult::allowedIf($operation != 'view' || $paragraph->status->value);
     if ($paragraph->getParentEntity() != NULL) {
       // Delete permission on the paragraph, should just depend on 'update'
       // access permissions on the parent.
       $operation = ($operation == 'delete') ? 'update' : $operation;
-      $parent_access = $paragraph->getParentEntity()->access($operation, $account, TRUE);
-      return AccessResult::allowedIf($operation != 'view' || $paragraph->status->value)
-        ->andIf($parent_access);
+      // Library items have no support for parent entity access checking.
+      if ($paragraph->getParentEntity()->getEntityTypeId() != 'paragraphs_library_item') {
+        $parent_access = $paragraph->getParentEntity()->access($operation, $account, TRUE);
+        $access_result = $access_result->andIf($parent_access);
+      }
     }
-    return AccessResult::allowedIf($operation != 'view' || $paragraph->status->value);
+    return $access_result;
   }
 
   /**