From cd32b1047a059b1124953d8870b56ed6664d48ba Mon Sep 17 00:00:00 2001 From: Paul Andrieux Date: Thu, 20 Sep 2018 18:31:06 +0200 Subject: [PATCH] remove obsolete class --- Helper/UserHelper.php | 101 ------------------------------------------ 1 file changed, 101 deletions(-) delete mode 100644 Helper/UserHelper.php diff --git a/Helper/UserHelper.php b/Helper/UserHelper.php deleted file mode 100644 index ca1fd3a..0000000 --- a/Helper/UserHelper.php +++ /dev/null @@ -1,101 +0,0 @@ -mangopayHelper = $mangopayHelper; - $this->entityManager = $entityManager; - $this->dispatcher = $dispatcher; - } - - public function findOrCreateMangoUser(UserInterface $user) - { - if ($mangoUserId = $user->getMangoUserId()) { - $mangoUser = $this->mangopayHelper->Users->get($mangoUserId); - } else { - $mangoUser = $this->createMangoUser($user); - } - - return $mangoUser; - } - - public function createMangoUser(UserInterface $user) - { - $birthdate = null; - if ($user->getBirthDate() instanceof \Datetime) { - $birthdate = $user->getBirthDate()->getTimestamp(); - } - $mangoUser = new UserNatural(); - $mangoUser->Email = $user->getEmail(); - $mangoUser->FirstName = $user->getFirstname(); - $mangoUser->LastName = $user->getLastname(); - $mangoUser->Birthday = $birthdate; - $mangoUser->Nationality = $user->getNationality(); - $mangoUser->CountryOfResidence = $user->getCountry(); - $mangoUser->Tag = $user->getId(); - - $mangoUser = $this->mangopayHelper->Users->Create($mangoUser); - - $event = new UserEvent($user, $mangoUser); - $this->dispatcher->dispatch(TroopersMangopayEvents::NEW_USER, $event); - - return $mangoUser; - } - - public function updateMangoUser(UserInterface $user) - { - if ($user->getBirthDate() instanceof \Datetime) { - $birthdate = $user->getBirthDate()->getTimestamp(); - } - $mangoUserId = $user->getMangoUserId(); - $mangoUser = $this->mangopayHelper->Users->get($mangoUserId); - - $mangoUser->Email = $user->getEmail(); - $mangoUser->FirstName = $user->getFirstname(); - $mangoUser->LastName = $user->getLastname(); - $mangoUser->Birthday = $birthdate; - $mangoUser->Nationality = $user->getNationality(); - $mangoUser->CountryOfResidence = $user->getCountry(); - $mangoUser->Tag = $user->getId(); - - $userAddress = $user->getAddress(); - $city = $user->getCity(); - $postalCode = $user->getPostalCode(); - $address = new \MangoPay\Address(); - $address->AddressLine1 = $userAddress; - $address->City = $city; - $address->Country = $user->getCountry(); - $address->PostalCode = $postalCode; - - $mangoUser->Address = $address; - - $mangoUser = $this->mangopayHelper->Users->Update($mangoUser); - - $this->entityManager->persist($user); - $this->entityManager->flush(); - - return $mangoUser; - } - - public function getTransactions($userId) - { - return $this->mangopayHelper->Users->GetTransactions($userId); - } -}