function CommentSelection::validateReferenceableNewEntities
Same name in other branches
- 8.9.x core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection::validateReferenceableNewEntities()
- 10 core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection::validateReferenceableNewEntities()
- 11.x core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php \Drupal\comment\Plugin\EntityReferenceSelection\CommentSelection::validateReferenceableNewEntities()
Overrides DefaultSelection::validateReferenceableNewEntities
File
-
core/
modules/ comment/ src/ Plugin/ EntityReferenceSelection/ CommentSelection.php, line 54
Class
- CommentSelection
- Provides specific access control for the comment entity type.
Namespace
Drupal\comment\Plugin\EntityReferenceSelectionCode
public function validateReferenceableNewEntities(array $entities) {
$entities = parent::validateReferenceableNewEntities($entities);
// Mirror the conditions checked in buildEntityQuery().
if (!$this->currentUser
->hasPermission('administer comments')) {
$entities = array_filter($entities, function ($comment) {
/** @var \Drupal\comment\CommentInterface $comment */
return $comment->isPublished();
});
}
return $entities;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.