comparison core/modules/comment/src/Controller/CommentController.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
277 $account = $this->currentUser(); 277 $account = $this->currentUser();
278 278
279 // Check if the user has the proper permissions. 279 // Check if the user has the proper permissions.
280 $access = AccessResult::allowedIfHasPermission($account, 'post comments'); 280 $access = AccessResult::allowedIfHasPermission($account, 'post comments');
281 281
282 // If commenting is open on the entity.
282 $status = $entity->{$field_name}->status; 283 $status = $entity->{$field_name}->status;
283 $access = $access->andIf(AccessResult::allowedIf($status == CommentItemInterface::OPEN) 284 $access = $access->andIf(AccessResult::allowedIf($status == CommentItemInterface::OPEN)
284 ->addCacheableDependency($entity)); 285 ->addCacheableDependency($entity))
286 // And if user has access to the host entity.
287 ->andIf(AccessResult::allowedIf($entity->access('view')));
285 288
286 // $pid indicates that this is a reply to a comment. 289 // $pid indicates that this is a reply to a comment.
287 if ($pid) { 290 if ($pid) {
288 // Check if the user has the proper permissions. 291 // Check if the user has the proper permissions.
289 $access = $access->andIf(AccessResult::allowedIfHasPermission($account, 'access comments')); 292 $access = $access->andIf(AccessResult::allowedIfHasPermission($account, 'access comments'));