function PollTotalVotes::render in Poll 8
Parameters
\Drupal\views\ResultRow $values:
Return value
mixed
Overrides FieldPluginBase::render
File
- src/
Plugin/ views/ field/ PollTotalVotes.php, line 21
Class
- PollTotalVotes
- Field handler which shows the total votes for a poll.
Namespace
Drupal\poll\Plugin\views\fieldCode
function render(ResultRow $values) {
/** @var \Drupal\poll\PollVoteStorage $vote_storage */
$vote_storage = \Drupal::service('poll_vote.storage');
$entity = Poll::load($this
->getValue($values));
$build['#markup'] = $vote_storage
->getTotalVotes($entity);
$build['#cache']['tags'][] = 'poll-votes:' . $entity
->id();
return $build;
}