/** * @param array $memberData * @return Member */ public function registerNewMember(array $memberData) { $hydrator = new DoctrineHydrator($this->getEntityManager()); $member = new Member(); $member->setServiceLocator($this->getServiceLocator()); $member = $hydrator->hydrate($memberData, $member); $entityManager = $this->getEntityManager(); $entityManager->persist($member); $entityManager->flush(); $mailService = $this->getMailService(); $message = $mailService->prepareMessage('signup', array('member' => $member)); $message->addTo($member->getEmail(), $member->getName()); $message->setSubject('USCSS New Member Confirmation'); $mailService->send($message); return $member; }
/** * @param ObjectManager $entityManager */ public function load(ObjectManager $entityManager) { echo "Loading member data.\n"; $members = array(array("firstName" => "Claire", "lastName" => "Matthews", "email" => "*****@*****.**", "website" => "http://www.kaijukennels.com", "phone" => "(310) 795-2523", "status" => 2, "judge" => 0, "official" => 0, "street" => "21419 Wardham Ave", "city" => "Lakewood", "state" => "CA", "postalCode" => "90715"), array("firstName" => "Julie", "lastName" => "Sandoval", "email" => "*****@*****.**", "phone" => "(818) 399-6778", "status" => 2, "judge" => 1, "official" => 0, "street" => "35640 Crown Valley Rd", "city" => "Acton", "state" => "CA", "postalCode" => "93510"), array("firstName" => "Daneen", "lastName" => "Fox", "email" => "*****@*****.**", "phone" => "(818) 585-8057", "status" => 1, "judge" => 1, "official" => 1, "street" => "35640 Crown Valley Rd", "city" => "Acton", "state" => "CA", "postalCode" => "93510")); $memberService = $this->getServiceLocator()->get('Application\\Service\\MemberService'); foreach ($members as $memberData) { if (!isset($memberData['password'])) { $memberData['password'] = $memberService->generatePassword(); } $member = new Member(); $member->setServiceLocator($this->getServiceLocator()); $hydrator = new ClassMethods(); $hydrator->hydrate($memberData, $member); $entityManager->persist($member); } $entityManager->flush(); }