コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getUserAchievement()
 {
     if (is_null($this->userAchievement)) {
         $className = $this->repository->getClassName();
         $this->userAchievement = new $className();
         $this->userAchievement->setAchievement($this->getOptions()->getId());
         $this->userAchievement->setUser($this->user);
         $userAchievement = $this->repository->getAchievement($this->getOptions()->getId(), $this->user);
         if (!is_null($userAchievement)) {
             $this->userAchievement = $userAchievement;
             $this->isComplete = !is_null($userAchievement->getCompleteAt()) ? true : false;
         }
     }
     return $this->userAchievement;
 }
コード例 #2
0
 /**
  * Get unlocked achievements
  *
  * @param string|null $category
  *
  * @return AchievementListenerInterface[]
  */
 public function getUnlockedAchievements($category = null)
 {
     if (!$this->user instanceof UserInterface) {
         return array();
     }
     $achievements = array();
     $types = $this->checkerLocator->getTypes($category);
     $userAchievements = $this->repository->findAchievements($this->user, $types, true);
     foreach ($userAchievements as $userAchievement) {
         $listener = $this->get($userAchievement->getAchievement());
         $listener->setUserAchievement($userAchievement);
         $achievements[] = $listener;
     }
     return $achievements;
 }