function bindUserDevicesEntity($userDevicesEntity) { if ($userDevicesEntity != null) { $userDevicesDto = new UserDevicesDto(); $userDevicesDto->setUserDevicesId($userDevicesEntity->getUserDevicesId()); $userDevicesDto->setUser(bindUserEntity($userDevicesEntity->getUser())); $userDevicesDto->setDevicesType(bindDevicesTypeEntity($userDevicesEntity->getDevicesType())); $userDevicesDto->setDeviceName($userDevicesEntity->getDeviceName()); $userDevicesDto->setDeviceId($userDevicesEntity->getDeviceId()); return $userDevicesDto; } else { return null; } }
$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*/