comparison core/modules/comment/src/CommentAccessControlHandler.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
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
124 /** @var \Drupal\comment\CommentInterface $entity */ 124 /** @var \Drupal\comment\CommentInterface $entity */
125 $entity = $items->getEntity(); 125 $entity = $items->getEntity();
126 $commented_entity = $entity->getCommentedEntity(); 126 $commented_entity = $entity->getCommentedEntity();
127 $anonymous_contact = $commented_entity->get($entity->getFieldName())->getFieldDefinition()->getSetting('anonymous'); 127 $anonymous_contact = $commented_entity->get($entity->getFieldName())->getFieldDefinition()->getSetting('anonymous');
128 $admin_access = AccessResult::allowedIfHasPermission($account, 'administer comments'); 128 $admin_access = AccessResult::allowedIfHasPermission($account, 'administer comments');
129 $anonymous_access = AccessResult::allowedIf($entity->isNew() && $account->isAnonymous() && ($anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT || $is_name) && $account->hasPermission('post comments')) 129 $anonymous_access = AccessResult::allowedIf($entity->isNew() && $account->isAnonymous() && ($anonymous_contact != CommentInterface::ANONYMOUS_MAYNOT_CONTACT || $is_name) && $account->hasPermission('post comments'))
130 ->cachePerPermissions() 130 ->cachePerPermissions()
131 ->addCacheableDependency($entity) 131 ->addCacheableDependency($entity)
132 ->addCacheableDependency($field_definition->getConfig($commented_entity->bundle())) 132 ->addCacheableDependency($field_definition->getConfig($commented_entity->bundle()))
133 ->addCacheableDependency($commented_entity); 133 ->addCacheableDependency($commented_entity);
134 return $admin_access->orIf($anonymous_access); 134 return $admin_access->orIf($anonymous_access);