public function FieldVoteResultBase::getVotesForField in Votingapi Widgets 8
Get votes for field.
Overrides FieldVoteResultInterface::getVotesForField
3 calls to FieldVoteResultBase::getVotesForField()
- FieldAverage::calculateResult in src/
Plugin/ VoteResultFunction/ FieldAverage.php - Calculate results.
- FieldCount::calculateResult in src/
Plugin/ VoteResultFunction/ FieldCount.php - Calculate results.
- FieldUseful::calculateResult in src/
Plugin/ VoteResultFunction/ FieldUseful.php - Calculate results.
File
- src/
FieldVoteResultBase.php, line 15
Class
- FieldVoteResultBase
- FieldVoteResultBase class.
Namespace
Drupal\votingapi_widgetsCode
public function getVotesForField($votes) {
$plugin_id = explode('.', $this
->getDerivativeId());
$field_name = $plugin_id[1];
foreach ($votes as $key => $vote) {
if ($vote->field_name->value != $field_name) {
unset($votes[$key]);
}
}
return $votes;
}