function bindNewsEntityArray($newsEntitys) { $newsDtos = new NewsListDto(); $newsDtoArray = array(); foreach ($newsEntitys as $newsEntity => $value) { array_push($newsDtoArray, bindNewsEntity($value)); } $newsDtos->setNewss($newsDtoArray); return $newsDtos; }
$newsListDto = new NewsListDto(); $newsListDto = $newsListDto->bindXml($app); foreach ($newsListDto->getNewss() as $newsDto) { $newsEntity = bindNewsDto($newsDto); $entityManager->persist($newsEntity); $entityManager->flush(); } }); $app->put('/newss/:id', function ($id) use($app) { global $entityManager; $newsEntity = $entityManager->find("NewsEntity", $id); $entityManager->flush(); $newsDto = bindNewsEntity($newsEntity); $newsDto->printData($app); }); $app->post('/newss', function () use($app) { global $entityManager; $newsDto = new NewsDto(); $newsDto->bindJson($app); $entityManager->persist($newsEntity); $entityManager->flush(); $newsDto = bindNewsEntity($newsEntity); $newsDto->printData($app); }); $app->delete('/newss/:id', function ($id) use($app) { global $entityManager; $newsEntity = $entityManager->find("NewsEntity", $id); $entityManager->remove($newsEntity); $entityManager->flush(); }); /*Referances*/