public CommentAdminOverview::submitForm(array &$form, FormStateInterface $form_state)
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- core/modules/comment/src/Form/CommentAdminOverview.php, line 255
Class
- CommentAdminOverview
- Provides the comments overview administration form.
Namespace
Drupal\comment\Form
Code
public function submitForm(array &$form, FormStateInterface $form_state) { $operation = $form_state->getValue('operation'); $cids = $form_state->getValue('comments'); 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); $comment->save(); } elseif ($operation == 'publish') { $comment = $this->commentStorage->load($cid); $comment->setPublished(TRUE); $comment->save(); } } drupal_set_message($this->t('The update has been performed.')); $form_state->setRedirect('comment.admin'); }
Please login to continue.