function bindUserDevicesEntityArray($userDevicesEntitys) { $userDevicesDtos = new UserDevicesListDto(); $userDevicesDtoArray = array(); foreach ($userDevicesEntitys as $userDevicesEntity => $value) { array_push($userDevicesDtoArray, bindUserDevicesEntity($value)); } $userDevicesDtos->setUserDevicess($userDevicesDtoArray); return $userDevicesDtos; }
$userDevicesListDto = new UserDevicesListDto(); $userDevicesListDto = $userDevicesListDto->bindXml($app); foreach ($userDevicesListDto->getUserDevicess() as $userDevicesDto) { $userDevicesEntity = bindUserDevicesDto($userDevicesDto); $entityManager->persist($userDevicesEntity); $entityManager->flush(); } }); $app->put('/userdevicess/:id', function ($id) use($app) { global $entityManager; $userDevicesEntity = $entityManager->find("UserDevicesEntity", $id); $entityManager->flush(); $userDevicesDto = bindUserDevicesEntity($userDevicesEntity); $userDevicesDto->printData($app); }); $app->post('/userdevicess', function () use($app) { global $entityManager; $userDevicesDto = new UserDevicesDto(); $userDevicesDto->bindJson($app); $entityManager->persist($userDevicesEntity); $entityManager->flush(); $userDevicesDto = bindUserDevicesEntity($userDevicesEntity); $userDevicesDto->printData($app); }); $app->delete('/userdevicess/:id', function ($id) use($app) { global $entityManager; $userDevicesEntity = $entityManager->find("UserDevicesEntity", $id); $entityManager->remove($userDevicesEntity); $entityManager->flush(); }); /*Referances*/