/** * Create an account and send an email address. * * @param string $emailAddress * @param string $firstName * @param string $middleName * @param string $lastName * * @return Contact */ public function register($emailAddress, $firstName, $middleName, $lastName) { //Create the account $contact = new Contact(); $contact->setEmail($emailAddress); $contact->setFirstName($firstName); if (strlen($middleName) > 0) { $contact->setMiddleName($middleName); } $contact->setLastName($lastName); //Fix the gender $contact->setGender($this->getGeneralService()->findEntityById('gender', Gender::GENDER_UNKNOWN)); $contact->setTitle($this->getGeneralService()->findEntityById('title', Title::TITLE_UNKNOWN)); /* * Include all the optIns */ $contact->setOptIn($this->getEntityManager()->getRepository('Contact\\Entity\\OptIn')->findBy(['autoSubscribe' => OptIn::AUTO_SUBSCRIBE])); /** * @var $contact Contact */ $contact = $this->newEntity($contact); //Create a target $target = $this->getDeeplinkService()->createTargetFromRoute('community/contact/profile/view'); //Create a deep link for the user which redirects to the profile-page $deeplink = $this->getDeeplinkService()->createDeeplink($target, $contact); $email = $this->getEmailService()->create(); $this->getEmailService()->setTemplate("/auth/register:mail"); $email->setDisplayName($contact->getDisplayName()); $email->addTo($emailAddress); $email->setUrl($this->getDeeplinkService()->parseDeeplinkUrl($deeplink)); $this->getEmailService()->send(); return $contact; }