| @@ 86-93 (lines=8) @@ | ||
| 83 | 'badge' => $badge |
|
| 84 | ]); |
|
| 85 | ||
| 86 | if ($isUnlocked) { |
|
| 87 | $this->addFlash( |
|
| 88 | 'error', |
|
| 89 | sprintf( |
|
| 90 | '%s already has the badge "%s"', |
|
| 91 | $user->getUsername(), |
|
| 92 | $badge->getTitle() |
|
| 93 | ) |
|
| 94 | ); |
|
| 95 | ||
| 96 | return $this->redirectToRoute('admin_claimed_badge_index'); |
|
| @@ 39-46 (lines=8) @@ | ||
| 36 | $token = new UsernamePasswordToken($user, 'none', 'none', $user->getRoles()); |
|
| 37 | $isUnlockable = $this->get('security.access.decision_manager')->decide($token, ['view'], $badge); |
|
| 38 | ||
| 39 | if (!$isUnlockable) { |
|
| 40 | $this->addFlash('error', sprintf('%s does not have access to badge "%s"', |
|
| 41 | $user->getUsername(), |
|
| 42 | $badge->getTitle() |
|
| 43 | )); |
|
| 44 | ||
| 45 | return $this->redirectToRoute('admin_unlocked_badge_new'); |
|
| 46 | } |
|
| 47 | ||
| 48 | $isUnlocked = $this->get('badger.game.repository.unlocked_badge') |
|
| 49 | ->findOneBy([ |
|
| @@ 54-61 (lines=8) @@ | ||
| 51 | 'badge' => $badge |
|
| 52 | ]); |
|
| 53 | ||
| 54 | if ($isUnlocked) { |
|
| 55 | $this->addFlash('error', sprintf('%s already has the badge "%s"', |
|
| 56 | $user->getUsername(), |
|
| 57 | $badge->getTitle() |
|
| 58 | )); |
|
| 59 | ||
| 60 | return $this->redirectToRoute('admin_unlocked_badge_new'); |
|
| 61 | } |
|
| 62 | ||
| 63 | $unlockedBadgeFactory = $this->get('badger.game.unlocked_badge.factory'); |
|
| 64 | $unlockedBadge = $unlockedBadgeFactory->create($user, $badge); |
|
| @@ 114-118 (lines=5) @@ | ||
| 111 | 'badge' => $badge |
|
| 112 | ]); |
|
| 113 | ||
| 114 | if (null === $unlockedBadge) { |
|
| 115 | $this->addFlash('error', sprintf('%s has no badge named "%s"', $user->getUsername(), $badge->getTitle())); |
|
| 116 | ||
| 117 | return $this->redirectToRoute('admin_unlocked_badge_delete'); |
|
| 118 | } |
|
| 119 | ||
| 120 | $unlockedBadgeRemover = $this->get('badger.game.remover.unlocked_badge'); |
|
| 121 | $unlockedBadgeRemover->remove($unlockedBadge); |
|