/** * Get representative from api, save his, get district id * @param Representative $representative Representative object * * @return integer */ public function updateByRepresentativeInfo(Representative $representative) { $representativesFromApi = $this->ciceroService->findRepresentativeByOfficialData($representative->getFirstName(), $representative->getLastName(), $representative->getOfficialTitle()); if ($representativesFromApi) { return $this->updateRepresentativeStorage($representativesFromApi, $representative); } return false; }
/** * Generate representative username by name and set new username * * @param Representative $representative * @param int $iteration * * @return string New username */ public function generateRepresentativeUsername(Representative $representative, $iteration = 0) { // Generate canonical name $name = $representative->getFirstName() . $representative->getLastName(); $name = preg_replace('/[^\\w]/i', '', $name); $name = strtolower($name); $name = $iteration ? $name . $iteration : $name; $representByUsername = $this->entityManager->getRepository('CivixCoreBundle:Representative')->findOneBy(array('username' => $name)); if (is_null($representByUsername)) { $representative->setUsername($name); } else { $name = $this->generateRepresentativeUsername($representative, ++$iteration); } return $name; }
public static function toRepresentativeOwnerData(Representative $representative) { $data = ['id' => $representative->getId(), 'type' => $representative->getType(), 'official_title' => $representative->getOfficialTitle(), 'first_name' => $representative->getFirstName(), 'last_name' => $representative->getLastName(), 'avatar_file_path' => $representative->getAvatarFileName()]; if ($representative->getStorageId()) { $data['storage_id'] = $representative->getStorageId(); } return $data; }
public function sendToApprovedRepresentative(Representative $representative, $username, $password) { $message = $this->createMessage('Representative Registration approved', $representative->getEmail(), 'CivixFrontBundle:Superuser:email/representative_approved.html.twig', array('name' => $representative->getFirstName() . ' ' . $representative->getLastName(), 'username' => $username, 'password' => $password)); $this->mailer->send($message); }
public function getLastName() { $this->__load(); return parent::getLastName(); }