FieldVoteResultBase.php in Votingapi Widgets 8
File
src/FieldVoteResultBase.php
View source
<?php
namespace Drupal\votingapi_widgets;
use Drupal\votingapi\VoteResultFunctionBase;
class FieldVoteResultBase extends VoteResultFunctionBase implements FieldVoteResultInterface {
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;
}
public function calculateResult($votes) {
return count($votes);
}
}