public function setLastActive($lastActive) { $this->__load(); return parent::setLastActive($lastActive); }
public function registerLocalAuthor($data) { $password = isset($data['password']['first']) ? $this->encoder->encodePassword($data['password']['first'], '') : null; $email = isset($data['fbId']) ? $data['email'] : $data['email']['first']; $localAuthor = new LocalAuthor(); $localAuthor->setFirstName($data['firstName']); $localAuthor->setLastName($data['lastName']); $localAuthor->setEmail($email); $localAuthor->setPassword($password); $localAuthor->setEmailVerified(1); // (isset($data['fbEmail']) && $email == $data['fbEmail']) ? $this->constants->get('EMAIL_VERIFIED') : $this->constants->get('EMAIL_UNVERIFIED') $localAuthor->setIsLocalAuthor($data['type']); $localAuthor->setDateJoined(new \DateTime(date('Y-m-d H:i:s'))); $localAuthor->setStatus(0); $localAuthor->setStreetCredit(0); $localAuthor->setIsApproved(1); $localAuthor->setIsBetaParticipant(isset($data['betaToken'])); $localAuthor->setLastActive(new \DateTime(date('Y-m-d H:i:s'))); $localAuthor->setLastInactiveNotificationSent(new \DateTime(date('Y-m-d H:i:s'))); $this->entityManager->persist($localAuthor); $bypassLocation = true; if ($data['type'] == 1 and !$bypassLocation) { // this is in preparation for when location would be non-required : Nash Lesigon - May 8, 2014 if (strlen(trim($data['country'])) && strlen(trim($data['city']))) { $location = new Location(); $location->setLocalAuthor($localAuthor); // find city by name, if not found create new city // data['city], data['country'] $country = $this->entityManager->getRepository('BugglMainBundle:Country')->findOneByName($data['country']); if (!is_null($country)) { $city = $this->entityManager->getRepository('BugglMainBundle:City')->findOneBy(array('name' => $data['city'], 'country' => $country)); if (is_null($city)) { $city = new City(); $city->setCountry($country); $city->setName($data['city']); $this->entityManager->persist($city); } $location->setCity($city); $this->entityManager->persist($location); } } } $this->entityManager->flush(); $profile = new Profile(); $profile->setLocalAuthor($localAuthor); if (isset($data['fbId'])) { $this->socialMediaService->saveFacebookInfo($data, $localAuthor); $tempPath = 'uploads/profile_pics'; $uploadRootDir = $this->serviceContainer->get('kernel')->getRootdir() . '/../web/' . $tempPath; $filename = 'fb_' . $data['fbId'] . '.jpg'; copy('https://graph.facebook.com/' . $data['fbId'] . '/picture?width=285&height=285', $uploadRootDir . '/' . $filename); $profile->setProfilePic($filename); $profile->setWork($data['fbWork']); $profile->setBirthDate($data['fbBirthday']); $this->entityManager->persist($profile); $this->entityManager->flush(); } else { if (isset($data['twitterId'])) { $this->socialMediaService->saveTwitterInfo($data, $localAuthor); } else { if (isset($data['googlePlusId'])) { $this->socialMediaService->saveGooglePlusInfo($data, $localAuthor); } else { $this->entityManager->persist($profile); $this->entityManager->flush(); } } } return $localAuthor; }