/**
  * @Route("/{optionId}/enter", name="giveaway_participant_entry_enter")
  * @ParamConverter("giveaway", class="StreamPerkGiveawayBundle:Giveaway")
  * @ParamConverter("giveawayEntryOption", class="StreamPerkGiveawayBundle:GiveawayEntryOption", options={"mapping": {"giveaway": "giveaway", "optionId": "id"}})
  * @Security("is_granted('SHOW', giveaway) and is_granted('SHOW', giveawayEntryOption)")
  */
 public function enterAction(Request $request, Giveaway $giveaway, GiveawayEntryOption $giveawayEntryOption)
 {
     if ($giveaway->isAvailable() === false) {
         return $this->redirectToRoute('giveaway_list');
     }
     $giveawayEntryTypeChain = $this->get('streamperk.giveaway.giveaway_entry_type_chain');
     $entryType = $giveawayEntryTypeChain->getGiveawayEntryType($giveawayEntryOption->getType());
     if ($this->isGranted($entryType->getPermissionAttribute(), $giveaway) === false) {
         throw $this->createAccessDeniedException(self::CANNOT_USE_THIS_ENTRY_TYPE_MSG);
     }
     $giveawayParticipantManager = $this->get('streamperk.giveaway_participant_manager');
     $giveawayParticipant = $giveawayParticipantManager->findOneBy(['giveaway' => $giveaway, 'user' => $this->getUser()]);
     if ($giveawayParticipant instanceof GiveawayParticipant === false) {
         $giveawayParticipant = $giveawayParticipantManager->createManagedEntity()->setGiveaway($giveaway)->setUser($this->getUser());
         if ($this->isGranted(AbstractVoter::CREATE, $giveawayParticipant) === false) {
             throw $this->createAccessDeniedException(self::CANNOT_PARTICIPATE_MSG);
         }
         $giveawayParticipantManager->persistAndFlush($giveawayParticipant);
     }
     $giveawayParticipantEntryManager = $this->get('streamperk.giveaway_participant_entry_manager');
     $giveawayParticipantEntry = $giveawayParticipantEntryManager->findOneBy(['entryOption' => $entryOption, 'participant' => $giveawayParticipant]);
     if ($giveawayParticipantEntry instanceof GiveawayParticipantEntry === false) {
         $giveawayParticipantEntry = $giveawayParticipantEntryManager->createManagedEntity()->setParticipant($giveawayParticipant)->setEntryOption($giveawayEntryOption);
         if ($this->isGranted(AbstractVoter::CREATE, $giveawayParticipantEntry) === false) {
             throw $this->createAccessDeniedException(self::CANNOT_ENTER_MSG);
         }
         $giveawayParticipantEntryManager->persistAndFlush($giveawayParticipantEntry);
     }
     return $this->redirectToRoute('giveaway_view', ['slug' => $giveaway->getSlug()]);
 }
 /**
  * @Route("/{slug}/view", name="giveaway_view")
  * @ParamConverter("giveaway", class="StreamPerkGiveawayBundle:Giveaway")
  * @Security("is_granted('SHOW', giveaway)")
  */
 public function viewAction(Request $request, Giveaway $giveaway)
 {
     if ($giveaway->isAvailable() === false) {
         return $this->redirectToRoute('giveaway_list');
     }
     $giveawayParticipantManager = $this->get('streamperk.giveaway_participant_manager');
     $giveawayParticipant = $giveawayParticipantManager->findOneBy(['giveaway' => $giveaway, 'user' => $this->getUser()]);
     $giveawayEntryTypeChain = $this->get('streamperk.giveaway.giveaway_entry_type_chain');
     $entryOptions = [];
     foreach ($giveaway->getEntryOptions() as $entryOption) {
         $entryType = $giveawayEntryTypeChain->getGiveawayEntryType($entryOption->getType());
         if ($this->isGranted(AbstractVoter::SHOW, $entryOption) === false || $this->isGranted($entryType->getPermissionAttribute(), $giveaway) === false) {
             continue;
         }
         $entryOptions[$entryOption->getId()] = [];
         $entryOptions[$entryOption->getId()]['option'] = $entryOption;
         $entryOptions[$entryOption->getId()]['type'] = $entryType;
         $entryOptions[$entryOption->getId()]['can_enter'] = true;
         if ($giveawayParticipant instanceof GiveawayParticipant) {
             $entryOptions[$entryOption->getId()]['can_enter'] = $entryType->isParticipantAllowed($giveawayParticipant);
             $entryOptions[$entryOption->getId()]['cannot_enter_reason'] = $entryType->getParticipantNotAllowedMessage($giveawayParticipant);
         }
     }
     return $this->render('StreamPerkGiveawayBundle:User:Giveaway/view.html.twig', ['giveaway' => $giveaway, 'giveawayParticipant' => $giveawayParticipant, 'entryOptions' => $entryOptions] + $this->getDefaultViewParameters());
 }