Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphAccessControlHandler.php
1 <?php
2
3 namespace Drupal\paragraphs;
4
5 use Drupal\Core\Entity\EntityAccessControlHandler;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Session\AccountInterface;
8 use Drupal\Core\Access\AccessResult;
9
10 /**
11  * Access controller for the paragraphs entity.
12  *
13  * @see \Drupal\paragraphs\Entity\Paragraph.
14  */
15 class ParagraphAccessControlHandler extends EntityAccessControlHandler {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function checkAccess(EntityInterface $paragraph, $operation, AccountInterface $account) {
21     // Allowed when the operation is not view or the status is true.
22     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
23     $access_result = AccessResult::allowedIf($operation != 'view' || $paragraph->status->value);
24     if ($paragraph->getParentEntity() != NULL) {
25       // Delete permission on the paragraph, should just depend on 'update'
26       // access permissions on the parent.
27       $operation = ($operation == 'delete') ? 'update' : $operation;
28       // Library items have no support for parent entity access checking.
29       if ($paragraph->getParentEntity()->getEntityTypeId() != 'paragraphs_library_item') {
30         $parent_access = $paragraph->getParentEntity()->access($operation, $account, TRUE);
31         $access_result = $access_result->andIf($parent_access);
32       }
33     }
34     return $access_result;
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
41     // Allowed when nobody implements.
42     return AccessResult::allowed();
43   }
44
45 }