You are here

public function VotingApiReactionManager::recallReaction in Voting API Reaction 8

Restore reaction from session variable.

Parameters

\Drupal\votingapi\Entity\Vote $entity: Current vote entity.

Return value

string|null Reaction vote id based on session.

1 call to VotingApiReactionManager::recallReaction()
VotingApiReactionManager::lastReaction in src/VotingApiReactionManager.php
Load previous reaction of the user for certain field.

File

src/VotingApiReactionManager.php, line 298

Class

VotingApiReactionManager
Manages reactions through Voting API entities.

Namespace

Drupal\votingapi_reaction

Code

public function recallReaction(Vote $entity) {
  $key = implode(':', [
    $entity
      ->getVotedEntityId(),
    $entity
      ->getVotedEntityType(),
    $entity
      ->get('field_name')->value,
  ]);
  return !empty($_SESSION['votingapi_reaction'][$key]) ? $_SESSION['votingapi_reaction'][$key] : NULL;
}