public function provider() { $genderTest = new GenderTest(); $titleTest = new TitleTest(); $contact = new Contact(); $contact->setFirstName('Jan'); $contact->setMiddleName('van der'); $contact->setLastName('Vliet'); $contact->setEmail('info+' . Rand::getString(4) . '@example.com'); $contact->setGender($genderTest->provider()[0][0]); $contact->setTitle($titleTest->provider()[0][0]); return [[$contact]]; }
public function testCanRenderCallNda() { $renderNda = new RenderNda(); $renderNda->setServiceLocator($this->serviceManager); $contact = new Contact(); $contact->setFirstName('Johan'); $contact->setLastName('van der Heide'); $nda = new Nda(); $nda->setContact($contact); $pdf = $renderNda->renderForCall($nda); $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf); $this->assertTrue(strlen($pdf->getPDFData()) > 0); }
public function testCanRenderDoa() { /** * Bootstrap the application to have the other information available */ $renderDoa = new RenderDoa(); $renderDoa->setServiceLocator($this->serviceManager); $contact = new Contact(); $contact->setFirstName('Johan'); $contact->setLastName('van der Heide'); $program = new Program(); $program->setProgram('testProgram'); $doa = new Doa(); $doa->setContact($contact); $doa->setProgram($program); $pdf = $renderDoa->renderForDoa($doa); $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf); $this->assertTrue(strlen($pdf->getPDFData()) > 0); }
/** * Body function, creating the contactObjects. */ private function prepareContent() { foreach ($this->content as $key => $content) { //See first if the contact can be found $contact = $this->getContactService()->findContactByEmail($content[$this->headerKeys['email']]); if (!is_null($contact)) { $contact->key = $key; $this->contacts[] = $contact; continue; } /** * 'organisation_id' => int 0 * 'organisation' => int 1 * 'firstname' => int 2 * 'middlename' => int 3 * 'lastname' => int 4 * 'position' => int 5 * 'email' => int 6 * 'phone' => int 7 * 'country' => int 8 * 'gender' => int 8 * 'title' => int 8 */ //Contact is not found $contact = new Contact(); $contact->key = $key; $contact->setFirstName($content[$this->headerKeys['firstname']]); $contact->setMiddleName($content[$this->headerKeys['middlename']]); $contact->setLastName($content[$this->headerKeys['lastname']]); $contact->setEmail($content[$this->headerKeys['email']]); $gender = null; $title = null; if (isset($this->headerKeys['gender']) && !empty($content[$this->headerKeys['gender']])) { $gender = $contact->setGender($this->getGeneralService()->findGenderByGender($content[$this->headerKeys['gender']])); } if (!is_null($gender)) { $contact->setGender($gender); } else { $contact->setGender($this->getGeneralService()->findEntityById('gender', Gender::GENDER_UNKNOWN)); } if (isset($this->headerKeys['title']) && !empty($content[$this->headerKeys['title']])) { $title = $contact->setTitle($this->getGeneralService()->findTitleByTitle($content[$this->headerKeys['title']])); } if (!is_null($title)) { $contact->setTitle($title); } else { $contact->setTitle($this->getGeneralService()->findEntityById('title', Title::TITLE_UNKNOWN)); } $contact->setPosition($content[$this->headerKeys['position']]); //If found, set the phone number if (isset($this->headerKeys['phone']) && !empty($content[$this->headerKeys['phone']])) { $phone = new Phone(); $phoneType = $this->getContactService()->findEntityById('phoneType', PhoneType::PHONE_TYPE_DIRECT); $phone->setType($phoneType); $phone->setPhone($content[$this->headerKeys['phone']]); $phone->setContact($contact); $phones = new ArrayCollection(); $phones->add($phone); $contact->setPhone($phones); } //Try to find the country $country = $this->getGeneralService()->findCountryByName($content[$this->headerKeys['country']]); //Try to find the organisation $organisationName = $content[$this->headerKeys['organisation']]; $organisation = null; if (isset($this->headerKeys['organisation_id']) && !empty($content[$this->headerKeys['organisation_id']])) { $organisation = $this->getOrganisationService()->setOrganisationId($content[$this->headerKeys['organisation_id']])->getOrganisation(); } if (is_null($organisation) && !is_null($country)) { $organisation = $this->getOrganisationService()->findOrganisationByNameCountry($organisationName, $country); } //If the organisation does not exist, create it if (is_null($organisation) && !is_null($country)) { $organisation = new Organisation(); $organisation->setOrganisation($organisationName); $organisation->setCountry($country); //Add the type $organisationType = $this->getOrganisationService()->findEntityById('type', Type::TYPE_UNKNOWN); $organisation->setType($organisationType); //Add the domain $validate = new EmailAddress(); $validate->isValid($content[$this->headerKeys['email']]); $organisationWebElements = new ArrayCollection(); $organisationWeb = new Web(); $organisationWeb->setWeb($validate->hostname); $organisationWeb->setMain(Web::MAIN); $organisationWeb->setOrganisation($organisation); $organisationWebElements->add($organisationWeb); if (isset($this->headerKeys['website']) && !is_null($content[$this->headerKeys['website']])) { //Strip the http:// and https:// $website = str_replace('http://', '', $content[$this->headerKeys['website']]); $website = str_replace('https://', '', $website); $organisationWebsite = new Web(); $organisationWebsite->setMain(Web::MAIN); $organisationWebsite->setWeb($website); $organisationWebsite->setOrganisation($organisation); $organisationWebElements->add($organisationWebsite); } $organisation->setWeb($organisationWebElements); } /** * If an organisation is found, add it to the contact */ if (!is_null($organisation)) { $contactOrganisation = new ContactOrganisation(); $contactOrganisation->setOrganisation($organisation); $contactOrganisation->setContact($contact); $contact->setContactOrganisation($contactOrganisation); } /** Add the contact to the contacts array */ $this->contacts[] = $contact; } }
/** * Send the email. */ public function send() { switch ($this->email->isPersonal()) { case true: foreach ($this->email->getTo() as $recipient => $contact) { /* * Create a new message for everyone */ $this->message = new Message(); $this->message->setEncoding('UTF-8'); $this->generateMessage(); //add the CC and BCC to the email $this->setShadowRecipients(); /* * We have a recipient which can be an instance of the contact. Produce a contactService object * and fill the templateVars with extra options */ if ($contact instanceof Contact) { $this->updateTemplateVarsWithContact($contact); } else { $contactName = $contact; $contact = new Contact(); $contact->setEmail($recipient); if (!is_null($contactName)) { $contact->setFirstName($contactName); } } /* * Overrule the to when we are in development */ if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) { $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName()); } else { $this->message->addTo($contact->getEmail(), $contact->getDisplayName()); } //$this->message->addTo($contact->getEmail(), $contact->getDisplayName()); /* * We have the contact and can now produce the content of the message */ $this->parseSubject(); /* * We have the contact and can now produce the content of the message */ $this->parseBody(); /* * Send the email */ $this->transport->send($this->message); } break; case false: /* * Create a new message for everyone */ $this->message = new Message(); $this->message->setEncoding('UTF-8'); $this->generateMessage(); //add the CC and BCC to the email $this->setShadowRecipients(); foreach ($this->email->getTo() as $recipient => $contact) { /* * We have a recipient which can be an instance of the contact. Produce a contactService object * and fill the templateVars with extra options */ if (!$contact instanceof Contact) { $contactName = $contact; $contact = new Contact(); $contact->setEmail($recipient); $contact->setFirstName($contactName); } /* * Overrule the to when we are in development */ if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) { $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName()); } else { $this->message->addTo($contact->getEmail(), $contact->getDisplayName()); } } /* * We have the contact and can now produce the content of the message */ $this->parseSubject(); /* * We have the contact and can now produce the content of the message */ $this->parseBody(); /* * Send the email */ $this->transport->send($this->message); break; } }
/** * 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; }