public function verifyClient(TeamspeakAccount $tsAccount, MinecraftAccount $mcAccount) { //unauthenticate any accounts with the same MC name but not the same UUID $mcqb = $this->entityManager->createQueryBuilder(); $mcqb->select('mcAccount')->from('PublicUHCTeamspeakAuthBundle:MinecraftAccount', 'mcAccount')->where($mcqb->expr()->andX($mcqb->expr()->eq('mcAccount.name', ':name'), $mcqb->expr()->neq('mcAccount.uuid', ':uuid')))->setParameter('name', $mcAccount->getName())->setParameter('uuid', $mcAccount->getUUID()); $accounts = $mcqb->getQuery()->getResult(Query::HYDRATE_OBJECT); /** @var $account MinecraftAccount */ foreach ($accounts as $account) { /** @var $authentication Authentication */ foreach ($account->getAuthentications()->getValues() as $authenitcation) { $this->unauthenticate($authenitcation); } } //verify the client $tsUUID = $tsAccount->getUUID(); $this->setDescriptionForUUID($mcAccount->getName(), $tsUUID); //attempt to remove them from the group first try { $this->removeUUIDFromGroup($tsUUID, $this->groupID); } catch (\TeamSpeak3_Exception $ex) { } $this->addUUIDToGroup($tsUUID, $this->groupID); $authenitcation = new Authentication(); $authenitcation->setMinecraftAccount($mcAccount)->setTeamspeakAccount($tsAccount); $this->entityManager->persist($authenitcation); $tsAccount->getCodes()->clear(); $mcAccount->getCodes()->clear(); $this->entityManager->flush(); $playerIcon = $this->mcHelper->getIconForUsername($mcAccount->getName()); $this->setIconForUUID($tsUUID, $playerIcon); }