You are here

public static function EntityLikeDislikeVoteCallback::pageCallback in Like & Dislike 7

Handles the when a node or comment is voted with a like. This functions uses a general function to register the vote This function is to be used with AJAX so just prints the counts and message

File

src/Controllers/PageControllers/EntityLikeDislikeVoteCallback.php, line 34

Class

EntityLikeDislikeVoteCallback
@file

Namespace

Drupal\like_and_dislike\Controllers\PageControllers

Code

public static function pageCallback() {
  $entity_type = arg(1);
  $vote_tag = arg(2);
  $entity_id = arg(3);
  if (isset($entity_type) && isset($vote_tag) && isset($entity_id)) {
    $return = \Drupal\like_and_dislike\Model\Vote::add($entity_id, $entity_type, $vote_tag);
    print $return['likes'] . "/" . $return['dislikes'] . "/" . $return['message'];
  }
}