Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function findByLinkedin(LinkedinUser $linkedinUser, User $user = null)
 {
     $linkedinUserTemp = $this->linkedinRepository->findByIdLinkedin($linkedinUser->getIdLinkedin());
     $arrLinkedinSkill = $this->linkedinSkillRepository->getOrCreateArray($linkedinUser->getLinkedinSkills());
     $skillResults = $arrLinkedinSkill['skill'];
     $linkedinSkillResults = $arrLinkedinSkill['linkedinSkill'];
     $linkedinUser->setLinkedinSkills($linkedinSkillResults);
     if (empty($linkedinUserTemp)) {
         $linkedinUserTemp = $this->persist($linkedinUser);
     } else {
         $linkedinUserTemp->updateFromAnother($linkedinUser);
         $this->entityManager->flush();
     }
     if (empty($user)) {
         /** @var User $user */
         $user = $this->repository->findUserByIdLinkedinUser($linkedinUserTemp->getId());
         if (empty($user)) {
             $user = $this->repository->createFromLinkedinUser($linkedinUserTemp);
             $user->setSkills($skillResults);
             $this->persist($user);
             $skills = $user->getSkills();
             $counts = $linkedinUserTemp->getCounts();
             $i = 0;
             foreach ($skills as $skill) {
                 $this->repository->newNumberForSkill($user, $skill, $counts[$i++], 1);
             }
         } else {
             foreach ($skillResults as $skill) {
                 $user->addSkill($skill);
             }
             $this->entityManager->flush();
         }
     } else {
         $user->setLinkedinUser($linkedinUserTemp);
         $this->entityManager->flush();
     }
     return $user;
 }
Beispiel #2
0
 /**
  * @param LinkedinUser $linkedinUser
  * @return $this
  */
 public function updateFromAnother(LinkedinUser $linkedinUser)
 {
     $this->setEmail($linkedinUser->getEmail());
     $this->setFirstName($linkedinUser->getFirstName());
     $this->setLastName($linkedinUser->getLastName());
     $this->setNumConnections($linkedinUser->getNumConnections());
     $this->setPictureUrl($linkedinUser->getPictureUrl());
     $this->setSiteUrl($linkedinUser->getSiteUrl());
     $this->setLinkedinSkills($linkedinUser->getLinkedinSkills());
     $this->setCounts($linkedinUser->getCounts());
     return $this;
 }