Пример #1
0
function bindAppointmentEntityArray($appointmentEntitys)
{
    $appointmentDtos = new AppointmentListDto();
    $appointmentDtoArray = array();
    foreach ($appointmentEntitys as $appointmentEntity => $value) {
        array_push($appointmentDtoArray, bindAppointmentEntity($value));
    }
    $appointmentDtos->setAppointments($appointmentDtoArray);
    return $appointmentDtos;
}
    $entityManager->flush();
    $appointmentDto = bindAppointmentEntity($appointmentEntity);
    $appointmentDto->printData($app);
});
$app->post('/appointments/list', function () use($app) {
    global $entityManager;
    $appointmentListDto = new AppointmentListDto();
    $appointmentListDto = $appointmentListDto->bindXml($app);
    $appointmentsArray = array();
    foreach ($appointmentListDto->getAppointments() as $appointmentDto) {
        $appointmentEntity = bindAppointmentDto($appointmentDto);
        $entityManager->persist($appointmentEntity);
        $entityManager->flush();
        array_push($appointmentsArray, bindAppointmentEntity($appointmentEntity));
    }
    $appointmentListDto = new AppointmentListDto();
    $appointmentListDto->setAppointments($appointmentsArray);
    $appointmentListDto->printData($app);
});
$app->put('/appointments/:id', function ($id) use($app) {
    global $entityManager;
    $appointmentEntity = $entityManager->find("AppointmentEntity", $id);
    $entityManager->flush();
    $appointmentDto = bindAppointmentEntity($appointmentEntity);
    $appointmentDto->printData($app);
});
$app->delete('/appointments/:id', function ($id) use($app) {
    global $entityManager;
    $appointmentEntity = $entityManager->find("AppointmentEntity", $id);
    $entityManager->remove($appointmentEntity);
    $entityManager->flush();