function like_and_dislike_vote_insert in Like & Dislike 8
Insert the like/dislike value if the user has select it.
File
- ./
like_and_dislike.module, line 117 - This module provides 2 voting widgets: Like and Dislike.
Code
function like_and_dislike_vote_insert(EntityInterface $vote) {
$vote_type_to_delete = '';
switch ($vote
->bundle()) {
case 'like':
$vote_type_to_delete = 'dislike';
break;
case 'dislike':
$vote_type_to_delete = 'like';
break;
}
if (!empty($vote_type_to_delete)) {
$vote_storage = \Drupal::entityTypeManager()
->getStorage('vote');
$vote_storage
->deleteUserVotes($vote
->getOwnerId(), $vote_type_to_delete, $vote
->getVotedEntityType(), $vote
->getVotedEntityId());
}
}