public function FieldUseful::calculateResult in Votingapi Widgets 8
Calculate results.
Overrides FieldVoteResultBase::calculateResult
File
- src/
Plugin/ VoteResultFunction/ FieldUseful.php, line 22
Class
- FieldUseful
- A sum of a set of votes.
Namespace
Drupal\votingapi_widgets\Plugin\VoteResultFunctionCode
public function calculateResult($votes) {
$total = 0;
$votes = $this
->getVotesForField($votes);
foreach ($votes as $vote) {
if ($vote->value->value == 1) {
$total++;
}
}
return $total;
}