- public function getConfirmText() {
- return $this->t('Delete comments');
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state) {
- $edit = $form_state->getUserInput();
-
- $form['comments'] = [
- '#prefix' => '<ul>',
- '#suffix' => '</ul>',
- '#tree' => TRUE,
- ];
- // array_filter() returns only elements with actual values.
- $comment_counter = 0;
- $this->comments = $this->commentStorage->loadMultiple(array_keys(array_filter($edit['comments'])));
- foreach ($this->comments as $comment) {
- $cid = $comment->id();
- $form['comments'][$cid] = [
- '#type' => 'hidden',
- '#value' => $cid,
- '#prefix' => '<li>',
- '#suffix' => Html::escape($comment->label()) . '</li>'
- ];
- $comment_counter++;
- }
- $form['operation'] = ['#type' => 'hidden', '#value' => 'delete'];
-
- if (!$comment_counter) {
- drupal_set_message($this->t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'));
- $form_state->setRedirect('comment.admin');
- }
-
- return parent::buildForm($form, $form_state);
+ protected function getDeletedMessage($count) {
+ return $this->formatPlural($count, 'Deleted @count comment.', 'Deleted @count comments.');