예제 #1
0
 /**
  * @param $data
  * @param $userId
  * @param UserInterface $adminUser
  * @return bool
  */
 public function addCoinsForm($data, $userId, UserInterface $adminUser)
 {
     $form = $this->adminCoinForm;
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     $user = $this->getUser4Id($userId);
     if ($user) {
         $data = $form->getData();
         $this->addCoins($user, $data['coins']);
         $class = $this->entityOptions->getDonateLog();
         /** @var \PServerCore\Entity\DonateLog $donateEntity */
         $donateEntity = new $class();
         $donateEntity->setTransactionId('AdminPanel: ' . $adminUser->getUsername())->setCoins($data['coins'])->setIp($this->ipService->getIp())->setSuccess($donateEntity::STATUS_SUCCESS)->setType($donateEntity::TYPE_INTERNAL)->setUser($user);
         $this->entityManager->persist($donateEntity);
         $this->entityManager->flush();
     }
     return true;
 }
예제 #2
0
 /**
  * Login with a User
  *
  * @param UserInterface $user
  */
 public function doAuthentication(UserInterface $user)
 {
     /** @var \PServerCore\Entity\Repository\User $repository */
     $repository = $this->entityManager->getRepository($this->getUserEntityClassName());
     // fix if we have a proxy we don´t have a valid entity, so we have to clear before we can create a new select
     $username = $user->getUsername();
     $repository->clear();
     $userNew = $repository->getUser4UserName($username);
     $authService = $this->getAuthService();
     $authService->getStorage()->write($userNew);
 }