function bindUserDeviceEntityArray($userDeviceEntitys) { $userDeviceDtos = new UserDeviceListDto(); $userDeviceDtoArray = array(); foreach ($userDeviceEntitys as $userDeviceEntity => $value) { array_push($userDeviceDtoArray, bindUserDeviceEntity($value)); } $userDeviceDtos->setUserDevices($userDeviceDtoArray); return $userDeviceDtos; }
$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(); }); /*Referances*/ function getuserDeviceQueryArray($app) { $queryArray = array(); $userDevicesId = $app->request()->get('userDevicesId'); if ($userDevicesId != null) { $queryArray['userDevicesId'] = $userDevicesId;