-
- foreach ($cids as $cid) {
- // Delete operation handled in \Drupal\comment\Form\ConfirmDeleteMultiple
- // see \Drupal\comment\Controller\AdminController::adminPage().
- if ($operation == 'unpublish') {
- $comment = $this->commentStorage->load($cid);
- $comment->setPublished(FALSE);
+ /** @var \Drupal\comment\CommentInterface[] $comments */
+ $comments = $this->commentStorage->loadMultiple($cids);
+ if ($operation != 'delete') {
+ foreach ($comments as $comment) {
+ if ($operation == 'unpublish') {
+ $comment->setUnpublished();
+ }
+ elseif ($operation == 'publish') {
+ $comment->setPublished();
+ }