Beispiel #1
0
 /**
  * @param Nette\Utils\ArrayHash $values
  * @return boolean Vytvoreni noveho uzivatele problehlo uspesne?
  */
 protected function newUser($values)
 {
     $result = TRUE;
     $userValues = $values->user;
     $personValues = $values->person;
     try {
         // pridani noveho uzivatele a ulozeni zmen
         $newUser = new User($userValues->login, $userValues->password, $userValues->role);
         $newPerson = new \App\Model\Entities\Person($personValues->name, $personValues->surname);
         if ($personValues->avatar->isImage()) {
             $this->imageStorage->setPersonAvatar($newPerson, $personValues->avatar->toImage());
         }
         $newUser->setPerson($newPerson);
         // ulozeni zmen
         $this->em->persist($newUser);
         $this->em->flush();
     } catch (\Exception $e) {
         \Tracy\Debugger::log($e, \Tracy\Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }