function bindUserEntityArray($userEntitys) { $userDtos = new UserListDto(); $userDtoArray = array(); foreach ($userEntitys as $userEntity => $value) { array_push($userDtoArray, bindUserEntity($value)); } $userDtos->setUsers($userDtoArray); return $userDtos; }
$entityManager->flush(); $userDto = bindUserEntity($userEntity); $userDto->printData($app); }); $app->post('/users/list', function () use($app) { global $entityManager; $userListDto = new UserListDto(); $userListDto = $userListDto->bindXml($app); $usersArray = array(); foreach ($userListDto->getUsers() as $userDto) { $userEntity = bindUserDto($userDto); $entityManager->persist($userEntity); $entityManager->flush(); array_push($usersArray, bindUserEntity($userEntity)); } $userListDto = new UserListDto(); $userListDto->setUsers($usersArray); $userListDto->printData($app); }); $app->put('/users/:id', function ($id) use($app) { global $entityManager; $userEntity = $entityManager->find("UserEntity", $id); $entityManager->flush(); $userDto = bindUserEntity($userEntity); $userDto->printData($app); }); $app->delete('/users/:id', function ($id) use($app) { global $entityManager; $userEntity = $entityManager->find("UserEntity", $id); $entityManager->remove($userEntity); $entityManager->flush();