You are here

function like_and_dislike_entity_load in Like & Dislike 7

Implementing hook_entity_load()

Loads the like/dislike information to the entity object

File

./like_and_dislike.module, line 97

Code

function like_and_dislike_entity_load($entities, $entity_type) {
  foreach ($entities as $entity_id => $entity) {
    $Entity = new \Drupal\like_and_dislike\Model\Entity($entity);
    if ($Entity
      ->voteIsAvailable()) {
      $entity->like = $Entity
        ->getLikesAmount();
      $entity->dislike = $Entity
        ->getDislikesAmount();
    }
  }
}