function bindDataContentEntityArray($dataContentEntitys) { $dataContentDtos = new DataContentListDto(); $dataContentDtoArray = array(); foreach ($dataContentEntitys as $dataContentEntity => $value) { array_push($dataContentDtoArray, bindDataContentEntity($value)); } $dataContentDtos->setDataContents($dataContentDtoArray); return $dataContentDtos; }
function bindNewsEntity($newsEntity) { if ($newsEntity != null) { $newsDto = new NewsDto(); $newsDto->setNewsId($newsEntity->getNewsId()); $newsDto->setNewsHeading($newsEntity->getNewsHeading()); $newsDto->setDataContent(bindDataContentEntity($newsEntity->getDataContent())); $newsDto->setNewsDate($newsEntity->getNewsDate()); return $newsDto; } else { return null; } }
function bindDoctorEntity($doctorEntity) { if ($doctorEntity != null) { $doctorDto = new DoctorDto(); $doctorDto->setDoctorId($doctorEntity->getDoctorId()); $doctorDto->setUser(bindUserEntity($doctorEntity->getUser())); $doctorDto->setIcon(bindImageEntity($doctorEntity->getIcon())); $doctorDto->setImage(bindImageEntity($doctorEntity->getImage())); $doctorDto->setBio(bindDataContentEntity($doctorEntity->getBio())); return $doctorDto; } else { return null; } }
function bindAppointmentEntity($appointmentEntity) { if ($appointmentEntity != null) { $appointmentDto = new AppointmentDto(); $appointmentDto->setAppointmentId($appointmentEntity->getAppointmentId()); $appointmentDto->setPractice(bindPracticeEntity($appointmentEntity->getPractice())); $appointmentDto->setUser(bindUserEntity($appointmentEntity->getUser())); $appointmentDto->setNote(bindDataContentEntity($appointmentEntity->getNote())); $appointmentDto->setExpectedFrm($appointmentEntity->getExpectedFrm()); $appointmentDto->setExpectedTo($appointmentEntity->getExpectedTo()); $appointmentDto->setActualFrm($appointmentEntity->getActualFrm()); $appointmentDto->setActualTo($appointmentEntity->getActualTo()); return $appointmentDto; } else { return null; } }
function bindPracticeEntity($practiceEntity) { if ($practiceEntity != null) { $practiceDto = new PracticeDto(); $practiceDto->setPracticeId($practiceEntity->getPracticeId()); $practiceDto->setName($practiceEntity->getName()); $practiceDto->setEmail($practiceEntity->getEmail()); $practiceDto->setLongitude($practiceEntity->getLongitude()); $practiceDto->setLatitude($practiceEntity->getLatitude()); $practiceDto->setAddress($practiceEntity->getAddress()); $practiceDto->setTradingDay(bindTradingDayEntity($practiceEntity->getTradingDay())); $practiceDto->setPhone($practiceEntity->getPhone()); $practiceDto->setFee($practiceEntity->getFee()); $practiceDto->setImage(bindImageEntity($practiceEntity->getImage())); $practiceDto->setBio(bindDataContentEntity($practiceEntity->getBio())); return $practiceDto; } else { return null; } }
$dataContentsArray = array(); foreach ($dataContentListDto->getDataContents() as $dataContentDto) { $dataContentEntity = bindDataContentDto($dataContentDto); $entityManager->persist($dataContentEntity); $entityManager->flush(); array_push($dataContentsArray, bindDataContentEntity($dataContentEntity)); } $dataContentListDto = new DataContentListDto(); $dataContentListDto->setDataContents($dataContentsArray); $dataContentListDto->printData($app); }); $app->put('/datacontents/:id', function ($id) use($app) { global $entityManager; $dataContentEntity = $entityManager->find("DataContentEntity", $id); $entityManager->flush(); $dataContentDto = bindDataContentEntity($dataContentEntity); $dataContentDto->printData($app); }); $app->delete('/datacontents/:id', function ($id) use($app) { global $entityManager; $dataContentEntity = $entityManager->find("DataContentEntity", $id); $entityManager->remove($dataContentEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/datacontents/:id/practices/bios', function ($id) use($app) { global $entityManager; $practiceEntities = $entityManager->getRepository("PracticeEntity")->findBy(array('bio' => $id)); $practice = bindPracticeEntityArray($practiceEntities); $practice->printData($app); });