You are here

protected function ApprovalPollViewForm::saveVote in Advanced Poll 8

Save vote.

Parameters

int $chId: Choice ID.

1 call to ApprovalPollViewForm::saveVote()
ApprovalPollViewForm::save in src/Form/ApprovalPollViewForm.php
Save a user's vote submit function.

File

src/Form/ApprovalPollViewForm.php, line 386

Class

ApprovalPollViewForm
Class ApprovalPollViewForm

Namespace

Drupal\advpoll\Form

Code

protected function saveVote($chId) {
  $options = array();
  $options['chid'] = $chId;
  $options['uid'] = $this
    ->currentUser()
    ->id();
  $options['pid'] = $this->poll
    ->id();
  $options['hostname'] = \Drupal::request()
    ->getClientIp();
  $options['timestamp'] = time();

  /** @var \Drupal\poll\PollVoteStorage $voteStorage */
  $voteStorage = \Drupal::service('poll_vote.storage');
  $voteStorage
    ->saveVote($options);
}