EntityLikeDislikeVoteCallback.php in Like & Dislike 7
File
src/Controllers/PageControllers/EntityLikeDislikeVoteCallback.php
View source
<?php
namespace Drupal\like_and_dislike\Controllers\PageControllers;
class EntityLikeDislikeVoteCallback implements \Drupal\cool\Controllers\PageController {
public static function getPath() {
return 'like_and_dislike/%/%/%';
}
public static function accessCallback() {
return TRUE;
}
public static function getDefinition() {
return array(
'type' => MENU_CALLBACK,
);
}
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'];
}
}
}