public static function VoteService::getEntityVoteAmount in Like & Dislike 7
This function gives back the number of votes for a particular entit with a particular type of voting. For example it can be used to get number of likes and also dislikes. Just need to change the type.
Parameters
type $entity_id the node id of the node for which number of votes is requited.:
type $vote_tag the category of vote: like/dislike etc.:
type $entity_type:
type $uid:
type $ip:
Return value
int
2 calls to VoteService::getEntityVoteAmount()
- Entity::getDislikesAmount in src/
Model/ Entity.php - Entity::getLikesAmount in src/
Model/ Entity.php
File
- src/
Services/ VoteService.php, line 21
Class
- VoteService
- @file
Namespace
Drupal\like_and_dislike\ServicesCode
public static function getEntityVoteAmount($entity_id, $vote_tag, $entity_type, $uid = NULL, $ip = NULL) {
if ($uid === NULL) {
$criteria = array(
'entity_id' => $entity_id,
'tag' => $vote_tag,
'entity_type' => $entity_type,
);
}
else {
$criteria = array(
'entity_id' => $entity_id,
'tag' => $vote_tag,
'uid' => $uid,
'entity_type' => $entity_type,
);
if ($ip != NULL) {
$criteria['vote_source'] = $ip;
}
}
$count = sizeof(votingapi_select_votes($criteria));
if (!isset($count)) {
$count = 0;
}
return $count;
}