function bindUserDeviceEntityArray($userDeviceEntitys) { $userDeviceDtos = new UserDeviceListDto(); $userDeviceDtoArray = array(); foreach ($userDeviceEntitys as $userDeviceEntity => $value) { array_push($userDeviceDtoArray, bindUserDeviceEntity($value)); } $userDeviceDtos->setUserDevices($userDeviceDtoArray); return $userDeviceDtos; }
$entityManager->flush(); $userDeviceDto = bindUserDeviceEntity($userDeviceEntity); $userDeviceDto->printData($app); }); $app->post('/userdevices/list', function () use($app) { global $entityManager; $userDeviceListDto = new UserDeviceListDto(); $userDeviceListDto = $userDeviceListDto->bindXml($app); $userDevicesArray = array(); foreach ($userDeviceListDto->getUserDevices() as $userDeviceDto) { $userDeviceEntity = bindUserDeviceDto($userDeviceDto); $entityManager->persist($userDeviceEntity); $entityManager->flush(); array_push($userDevicesArray, bindUserDeviceEntity($userDeviceEntity)); } $userDeviceListDto = new UserDeviceListDto(); $userDeviceListDto->setUserDevices($userDevicesArray); $userDeviceListDto->printData($app); }); $app->put('/userdevices/:id', function ($id) use($app) { global $entityManager; $userDeviceEntity = $entityManager->find("UserDeviceEntity", $id); $entityManager->flush(); $userDeviceDto = bindUserDeviceEntity($userDeviceEntity); $userDeviceDto->printData($app); }); $app->delete('/userdevices/:id', function ($id) use($app) { global $entityManager; $userDeviceEntity = $entityManager->find("UserDeviceEntity", $id); $entityManager->remove($userDeviceEntity); $entityManager->flush();