public function CommentAdminOverview::submitForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Form/CommentAdminOverview.php \Drupal\comment\Form\CommentAdminOverview::submitForm()
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 260 - Contains \Drupal\comment\Form\CommentAdminOverview.
Class
- CommentAdminOverview
- Provides the comments overview administration form.
Namespace
Drupal\comment\FormCode
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');
}