/**
  * @param array $data
  * @return UserInfo|false|null
  */
 public function create($data)
 {
     $uae = new AddUser($data);
     $uae = \Events::dispatch('on_before_user_add', $uae);
     if (!$uae->proceed()) {
         return false;
     }
     $db = $this->connection;
     $dh = $this->application->make('date');
     $uDateAdded = $dh->getOverridableNow();
     $config = $this->application->make('config');
     $hasher = new PasswordHash($config->get('concrete.user.password.hash_cost_log2'), $config->get('concrete.user.password.hash_portable'));
     if (isset($data['uIsValidated']) && $data['uIsValidated'] == 1) {
         $uIsValidated = 1;
     } elseif (isset($data['uIsValidated']) && $data['uIsValidated'] == 0) {
         $uIsValidated = 0;
     } else {
         $uIsValidated = -1;
     }
     if (isset($data['uIsFullRecord']) && $data['uIsFullRecord'] == 0) {
         $uIsFullRecord = 0;
     } else {
         $uIsFullRecord = 1;
     }
     $password_to_insert = isset($data['uPassword']) ? $data['uPassword'] : null;
     $hash = $hasher->HashPassword($password_to_insert);
     $uDefaultLanguage = null;
     if (isset($data['uDefaultLanguage']) && $data['uDefaultLanguage'] != '') {
         $uDefaultLanguage = $data['uDefaultLanguage'];
     }
     $v = array($data['uName'], $data['uEmail'], $hash, $uIsValidated, $uDateAdded, $uDateAdded, $uIsFullRecord, $uDefaultLanguage, 1);
     $r = $db->prepare("insert into Users (uName, uEmail, uPassword, uIsValidated, uDateAdded, uLastPasswordChange, uIsFullRecord, uDefaultLanguage, uIsActive) values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
     $res = $r->execute($v);
     if ($res) {
         $newUID = $db->Insert_ID();
         $ui = $this->userInfoFactory->getByID($newUID);
         if (is_object($ui)) {
             $uo = $ui->getUserObject();
             $groupControllers = \Group::getAutomatedOnRegisterGroupControllers($uo);
             foreach ($groupControllers as $ga) {
                 if ($ga->check($uo)) {
                     $uo->enterGroup($ga->getGroupObject());
                 }
             }
             // run any internal event we have for user add
             $ue = new UserInfoWithPassword($ui);
             $ue->setUserPassword($password_to_insert);
             \Events::dispatch('on_user_add', $ue);
         }
         return $ui;
     }
 }
 /**
  * @param array $data
  *
  * @return UserInfo|false|null
  */
 public function create($data)
 {
     $uae = new AddUser($data);
     $uae = \Events::dispatch('on_before_user_add', $uae);
     if (!$uae->proceed()) {
         return false;
     }
     $config = $this->application->make('config');
     $hasher = new PasswordHash($config->get('concrete.user.password.hash_cost_log2'), $config->get('concrete.user.password.hash_portable'));
     if (isset($data['uIsValidated']) && $data['uIsValidated'] == 1) {
         $uIsValidated = 1;
     } elseif (isset($data['uIsValidated']) && $data['uIsValidated'] == 0) {
         $uIsValidated = 0;
     } else {
         $uIsValidated = -1;
     }
     if (isset($data['uIsFullRecord']) && $data['uIsFullRecord'] == 0) {
         $uIsFullRecord = 0;
     } else {
         $uIsFullRecord = 1;
     }
     $password_to_insert = isset($data['uPassword']) ? $data['uPassword'] : null;
     $hash = $hasher->HashPassword($password_to_insert);
     $uDefaultLanguage = null;
     if (isset($data['uDefaultLanguage']) && $data['uDefaultLanguage'] != '') {
         $uDefaultLanguage = $data['uDefaultLanguage'];
     }
     $entity = new UserEntity();
     $entity->setUserName($data['uName']);
     $entity->setUserEmail($data['uEmail']);
     $entity->setUserPassword($hash);
     $entity->setUserIsValidated($uIsValidated);
     $entity->setUserIsFullRecord($uIsFullRecord);
     $entity->setUserDefaultLanguage($uDefaultLanguage);
     $entity->setUserIsActive(true);
     $this->entityManager->persist($entity);
     $this->entityManager->flush();
     $newUID = $entity->getUserID();
     $ui = $this->userInfoRepository->getByID($newUID);
     if (is_object($ui)) {
         $uo = $ui->getUserObject();
         $groupControllers = \Group::getAutomatedOnRegisterGroupControllers($uo);
         foreach ($groupControllers as $ga) {
             if ($ga->check($uo)) {
                 $uo->enterGroup($ga->getGroupObject());
             }
         }
         // run any internal event we have for user add
         $ue = new UserInfoWithPassword($ui);
         $ue->setUserPassword($password_to_insert);
         \Events::dispatch('on_user_add', $ue);
         // Now we notify any relevant users.
         /**
          * @var $type UserSignupType
          */
         $type = $this->application->make('manager/notification/types')->driver('user_signup');
         $u = new User();
         $createdBy = null;
         if (is_object($u)) {
             $creator = $u->getUserInfoObject();
             if (is_object($creator)) {
                 $createdBy = $creator->getEntityObject();
             }
         }
         $signup = new UserSignup($ui->getEntityObject(), $createdBy);
         $notifier = $type->getNotifier();
         $subscription = $type->getSubscription($signup);
         $notified = $notifier->getUsersToNotify($subscription, $signup);
         $notification = $type->createNotification($signup);
         $notifier->notify($notified, $notification);
     }
     return $ui;
 }