public function resumeAction(Resume $resume) { $helper = $this->get('Helper'); $currency = $helper->getCurrency(); foreach ($resume->getLanguages() as $item) { $languages[]['title'] = $item->getTitle(); } foreach ($resume->getEducation() as $item) { $education[]['title'] = $item->getTitle(); } foreach ($resume->getExperience() as $item) { $experience[]['title'] = $item->getTitle(); } $data['id'] = $resume->getId(); $data['name'] = $resume->getFirstName() . ' ' . $resume->getLastName(); $data['location'] = $resume->getCity()->getCountry()->translate()->getTitle() . ', ' . $resume->getCity()->translate()->getTitle(); $data['created'] = $resume->getCreated()->format('d.m.Y'); $data['salary'] = number_format($resume->getSalary()); $data['currency'] = $currency[$resume->getCurrency()]; $data['phone'] = $resume->getPhone(); $data['email'] = $resume->getEmail(); $data['skype'] = $resume->getSkype(); $data['education'] = isset($education) ? $education : ''; $data['languages'] = isset($languages) ? $languages : ''; $data['experience'] = isset($experience) ? $experience : ''; $data['comment'] = $resume->getExtra(); $data['specialty'] = $resume->getSpecialty(); $data['image'] = $resume->getImageSrc(); return new JsonResponse(['resume' => $data]); }
/** * @Route("/employee/resume/create", name="employee_resume_create") * @Template() */ public function resumeCreateAction(Request $request) { $em = $this->getDoctrine()->getManager(); $resume = new Resume(); $employee = $this->getUser(); $resume->addEducation(new \ApiBundle\Entity\Education()); $resume->addExperience(new \ApiBundle\Entity\Experience()); $resume->setFirstName($employee->getFirstName()); $resume->setLastName($employee->getLastName()); $resume->setMiddleName($employee->getMiddleName()); $resume->setBirthdate($employee->getBirthdate()); $form = $this->createForm(new ResumeType($em), $resume); $form->handleRequest($request); if ($form->isValid()) { $stringToDate = $resume->getTermfrom(); if (trim($stringToDate) != "") { $resume->setTermfrom(new \DateTime($stringToDate)); } else { $resume->setTermfrom(null); } $stringToDate = $resume->getTermto(); if (trim($stringToDate) != "") { $resume->setTermto(new \DateTime($stringToDate)); } else { $resume->setTermto(null); } $resume->setEmployee($employee); $employee->addResume($resume); foreach ($resume->getEducation() as $education) { if ($education->getUniversities() == null) { $resume->removeEducation($education); } else { $eduTitle = $education->getUniversities(); $universityObj = $em->getRepository("ApiBundle:Universities")->findOneBy(array('title' => $eduTitle)); $resume->removeEducation($education); $education->setUniversities($universityObj); $universityObj->addEducation($education); $education->setResume($resume); $resume->addEducation($education); // $em->persist($education); $em->persist($universityObj); $em->persist($education); } } // $resume->set(); foreach ($resume->getExperience() as $experience) { if ($experience->getTitle() == null) { $resume->removeExperience($experience); } else { $experience->setResume($resume); $em->persist($experience); } } $resume->setCreated(new \DateTime()); // $image = $em->getRepository('OneDayJobApiBundle:Image')->findOneBy(['title' => $employee->getId()]); $imageId = $request->request->get('mainbundle_resume')['imageId']; if ($imageId) { $image = $this->getDoctrine()->getRepository('ApiBundle:Image')->findOneById($imageId); if ($image) { $imageObject = $image; $this->cropImage($request, $image); $resume->setImage($imageObject); } } else { $img = $this->getUser()->getImage(); $resume->setImage($img); } // new ExecutableFinder(); // $em->persist($employee); $em->persist($resume); $em->flush(); // $session->getFlashBag()->add('success', $translator->trans('flash.success.resume.created')); return $this->redirectToRoute('employee_resume', array('from' => "created"), 301); } return $this->render('MainBundle:Employee:createResume.html.twig', ['form' => $form->createView()]); }