public function PollViewForm::cancel in Poll 8
Cancel vote submit function.
Parameters
array $form: The previous form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
File
- src/
Form/ PollViewForm.php, line 294
Class
- PollViewForm
- Displays banned IP addresses.
Namespace
Drupal\poll\FormCode
public function cancel(array $form, FormStateInterface $form_state) {
/** @var \Drupal\poll\PollVoteStorageInterface $vote_storage */
$vote_storage = \Drupal::service('poll_vote.storage');
$vote_storage
->cancelVote($this->poll, $this
->currentUser());
\Drupal::logger('poll')
->notice('%user\'s vote in Poll #%poll deleted.', array(
'%user' => $this
->currentUser()
->id(),
'%poll' => $this->poll
->id(),
));
$this
->messenger()
->addMessage($this
->t('Your vote was cancelled.'));
// In case of an ajax submission, trigger a form rebuild so that we can
// return an updated form through the ajax callback.
if ($this
->getRequest()->query
->get('ajax_form')) {
$form_state
->setRebuild(TRUE);
}
}