function bindPracticeEntityArray($practiceEntitys) { $practiceDtos = new PracticeListDto(); $practiceDtoArray = array(); foreach ($practiceEntitys as $practiceEntity => $value) { array_push($practiceDtoArray, bindPracticeEntity($value)); } $practiceDtos->setPractices($practiceDtoArray); return $practiceDtos; }
$entityManager->flush(); $practiceDto = bindPracticeEntity($practiceEntity); $practiceDto->printData($app); }); $app->post('/practices/list', function () use($app) { global $entityManager; $practiceListDto = new PracticeListDto(); $practiceListDto = $practiceListDto->bindXml($app); $practicesArray = array(); foreach ($practiceListDto->getPractices() as $practiceDto) { $practiceEntity = bindPracticeDto($practiceDto); $entityManager->persist($practiceEntity); $entityManager->flush(); array_push($practicesArray, bindPracticeEntity($practiceEntity)); } $practiceListDto = new PracticeListDto(); $practiceListDto->setPractices($practicesArray); $practiceListDto->printData($app); }); $app->put('/practices/:id', function ($id) use($app) { global $entityManager; $practiceEntity = $entityManager->find("PracticeEntity", $id); $entityManager->flush(); $practiceDto = bindPracticeEntity($practiceEntity); $practiceDto->printData($app); }); $app->delete('/practices/:id', function ($id) use($app) { global $entityManager; $practiceEntity = $entityManager->find("PracticeEntity", $id); $entityManager->remove($practiceEntity); $entityManager->flush();