email, firstName: $cmd->firstName, lastName: $cmd->lastName ); if ($cmd->password) { $user->setPassword($cmd->password); } if ($cmd->language) { $user->setLanguage($cmd->language); } if ($cmd->ip) { $user->setIp($cmd->ip); } if ($cmd->countryCode) { $user->setCountryCode($cmd->countryCode); } if ($cmd->cityName) { $user->setCityName($cmd->cityName); } if ($cmd->role) { $user->setRole($cmd->role); } if ($cmd->status) { $user->setStatus($cmd->status); } // Find the affiliate if ($cmd->refCode) { try { $affiliate = $this->affiliateRepo->ofCode($cmd->refCode); $user->setReferredBy($affiliate->getUser()); } catch (AffiliateNotFoundException $th) { //throw $th; } } $this->repo->add($user); // Dispatch the user created event $event = new UserCreatedEvent($user); $this->dispatcher->dispatch($event); return $user; } }