public function Sum::calculateResult in Voting API 8.3
Performs the calculations on a set of votes to derive the result.
Parameters
\Drupal\votingapi\Entity\Vote[] $votes: An array of Vote entities.
Return value
int A result based on the supplied votes.
Overrides VoteResultFunctionInterface::calculateResult
File
- src/
Plugin/ VoteResultFunction/ Sum.php, line 21
Class
- Sum
- A sum of a set of votes.
Namespace
Drupal\votingapi\Plugin\VoteResultFunctionCode
public function calculateResult($votes) {
$total = 0;
foreach ($votes as $vote) {
$total += $vote
->getValue();
}
return $total;
}