Esempio n. 1
0
 public function userInit()
 {
     $user = null;
     $email = $this->userValues["contact"]["email"];
     try {
         $user = $this->userService->getUserEmail($email);
     } catch (Exceptions\NoResultException $ex) {
         $this->logger->addDebug($ex);
     }
     if ($user === null) {
         $this->logger->addInfo("Users module initializer - User - no user with email {$email} found. New one is gonna be created.");
         $addrValues = $this->userValues["contact"]["address"];
         $address = new Address((array) $addrValues);
         $address->applyAccountNumber($this->userValues["contact"]["address"]["accountNumber"]);
         $address->applyIdentificationNumber($this->userValues["contact"]["address"]["identificationNumber"]);
         $address->applyTaxIdentificationNumber($this->userValues["contact"]["address"]["taxIdentificationNumber"]);
         $contValues = $this->userValues["contact"];
         $contact = new Contact((array) $contValues);
         $contact->setAddress($address);
         $userValues = $this->userValues;
         unset($userValues["contact"]);
         $user = new User((array) $userValues);
         $user->setActive(true);
         $user->setContact($contact);
         $user->setBirthNumber("0000000000");
         $this->userService->createUser($user);
     }
 }