public function VoteResultFunctionManager::getResults in Voting API 8.3
Get the voting results for an entity.
Parameters
string $entity_type_id: The type of entity, e.g. 'node'.
int $entity_id: The ID of the entity.
Return value
array A nested array
File
- src/
VoteResultFunctionManager.php, line 84
Class
- VoteResultFunctionManager
- Manages vote result plugins.
Namespace
Drupal\votingapiCode
public function getResults($entity_type_id, $entity_id) {
$results = [];
$result = $this->database
->select('votingapi_result', 'v')
->fields('v', [
'type',
'function',
'value',
])
->condition('entity_type', $entity_type_id)
->condition('entity_id', $entity_id)
->execute();
while ($row = $result
->fetchAssoc()) {
$results[$row['type']][$row['function']] = $row['value'];
}
return $results;
}