function bindUserEntityArray($userEntitys) { $userDtos = new UserListDto(); $userDtoArray = array(); foreach ($userEntitys as $userEntity => $value) { array_push($userDtoArray, bindUserEntity($value)); } $userDtos->setUsers($userDtoArray); return $userDtos; }
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 bindSessionEntity($sessionEntity) { if ($sessionEntity != null) { $sessionDto = new SessionDto(); $sessionDto->setSessionId($sessionEntity->getSessionId()); $sessionDto->setUser(bindUserEntity($sessionEntity->getUser())); $sessionDto->setSessionLocation($sessionEntity->getSessionLocation()); $sessionDto->setEffFrom($sessionEntity->getEffFrom()); $sessionDto->setEffTo($sessionEntity->getEffTo()); return $sessionDto; } else { return null; } }
function bindUserDeviceEntity($userDeviceEntity) { if ($userDeviceEntity != null) { $userDeviceDto = new UserDeviceDto(); $userDeviceDto->setUserDevicesId($userDeviceEntity->getUserDevicesId()); $userDeviceDto->setUser(bindUserEntity($userDeviceEntity->getUser())); $userDeviceDto->setType(bindDevicesTypeEntity($userDeviceEntity->getType())); $userDeviceDto->setName($userDeviceEntity->getName()); $userDeviceDto->setDevicePushId($userDeviceEntity->getDevicePushId()); return $userDeviceDto; } else { return null; } }
function bindTransactionEntity($transactionEntity) { if ($transactionEntity != null) { $transactionDto = new TransactionDto(); $transactionDto->setTransactionId($transactionEntity->getTransactionId()); $transactionDto->setTransactionTotal($transactionEntity->getTransactionTotal()); $transactionDto->setUser(bindUserEntity($transactionEntity->getUser())); $transactionDto->setTransactionType($transactionEntity->getTransactionType()); $transactionDto->setTransactionProof(bindTransactionProofEntity($transactionEntity->getTransactionProof())); $transactionDto->setTransactionDate($transactionEntity->getTransactionDate()); return $transactionDto; } else { return null; } }
function bindPrescriptionEntity($prescriptionEntity) { if ($prescriptionEntity != null) { $prescriptionDto = new PrescriptionDto(); $prescriptionDto->setPrescriptionId($prescriptionEntity->getPrescriptionId()); $prescriptionDto->setAppointment(bindAppointmentEntity($prescriptionEntity->getAppointment())); $prescriptionDto->setDoctor(bindDoctorEntity($prescriptionEntity->getDoctor())); $prescriptionDto->setUser(bindUserEntity($prescriptionEntity->getUser())); $prescriptionDto->setFile(bindFileEntity($prescriptionEntity->getFile())); $prescriptionDto->setEffFrm($prescriptionEntity->getEffFrm()); $prescriptionDto->setEffTo($prescriptionEntity->getEffTo()); return $prescriptionDto; } 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 bindUserCarEntity($userCarEntity) { if ($userCarEntity != null) { $userCarDto = new UserCarDto(); $userCarDto->setCarId($userCarEntity->getCarId()); $userCarDto->setUser(bindUserEntity($userCarEntity->getUser())); $userCarDto->setCarName($userCarEntity->getCarName()); $userCarDto->setCarNumPlate($userCarEntity->getCarNumPlate()); $userCarDto->setCarMake($userCarEntity->getCarMake()); $userCarDto->setCarModel($userCarEntity->getCarModel()); $userCarDto->setCarYear($userCarEntity->getCarYear()); $userCarDto->setCarColor($userCarEntity->getCarColor()); return $userCarDto; } else { return null; } }
$usersArray = array(); foreach ($userListDto->getUsers() as $userDto) { $userEntity = bindUserDto($userDto); $entityManager->persist($userEntity); $entityManager->flush(); array_push($usersArray, bindUserEntity($userEntity)); } $userListDto = new UserListDto(); $userListDto->setUsers($usersArray); $userListDto->printData($app); }); $app->put('/users/:id', function ($id) use($app) { global $entityManager; $userEntity = $entityManager->find("UserEntity", $id); $entityManager->flush(); $userDto = bindUserEntity($userEntity); $userDto->printData($app); }); $app->delete('/users/:id', function ($id) use($app) { global $entityManager; $userEntity = $entityManager->find("UserEntity", $id); $entityManager->remove($userEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/users/:id/userdevices/users', function ($id) use($app) { global $entityManager; $userDeviceEntities = $entityManager->getRepository("UserDeviceEntity")->findBy(array('user' => $id)); $userDevice = bindUserDeviceEntityArray($userDeviceEntities); $userDevice->printData($app); });