Ejemplo n.º 1
0
 private function addSearch($opportunity)
 {
     $organization = $opportunity->getOrganization();
     $skills = $opportunity->getSkills();
     $focuses = $organization->getFocuses();
     $search = new Search();
     $search->setDate(new \DateTime());
     $search->setType('opportunity');
     $search->setOrganization($organization);
     $search->setOpportunity($opportunity);
     foreach ($focuses as $focus) {
         $searchClone = clone $search;
         $searchClone->setFocus($focus);
         $this->em->persist($searchClone);
     }
     foreach ($skills as $skill) {
         $searchClone = clone $search;
         $searchClone->setSkill($skill);
         $this->em->persist($searchClone);
     }
     if (!isset($searchClone)) {
         $this->em->persist($search);
     }
     $this->em->flush();
 }
Ejemplo n.º 2
0
 public function setSearchRecord($data, $searched)
 {
     $search = new Search();
     $search->setDate(new \DateTime());
     $search->setType($searched);
     $em = $this->em;
     if ('opportunity' === $searched && !array_key_exists('focuses', $data) && !array_key_exists('skills', $data)) {
         $focus = $em->getRepository('TruckeeMatchBundle:Focus')->findOneBy(['focus' => 'All']);
         $search->setFocus($focus);
         $skill = $em->getRepository('TruckeeMatchBundle:Skill')->findOneBy(['skill' => 'All']);
         $search->setSkill($skill);
         $search->setType($searched);
         $em->persist($search);
     } else {
         if (array_key_exists('organization', $data) && '' != $data['organization']['organization']) {
             $orgId = $data['organization']['organization'];
             $organization = $em->getRepository('TruckeeMatchBundle:Organization')->find($orgId);
             $search->setOrganization($organization);
         }
         if (array_key_exists('opportunity', $data)) {
             $search->setOpportunity($data['opportunity']);
         }
         if (array_key_exists('focuses', $data)) {
             foreach ($data['focuses'] as $focusId) {
                 $searchClone = clone $search;
                 $focus = $em->getRepository('TruckeeMatchBundle:Focus')->find($focusId);
                 $searchClone->setFocus($focus);
                 $em->persist($searchClone);
             }
         }
         if (array_key_exists('skills', $data)) {
             foreach ($data['skills'] as $skillId) {
                 $skill = $em->getRepository('TruckeeMatchBundle:Skill')->find($skillId);
                 $searchClone = clone $search;
                 $searchClone->setSkill($skill);
                 $searchClone->setType($searched);
                 $em->persist($searchClone);
             }
         }
     }
     $em->flush();
 }