function bindDataContentEntity($dataContentEntity) { if ($dataContentEntity != null) { $dataContentDto = new DataContentDto(); $dataContentDto->setDataContentId($dataContentEntity->getDataContentId()); $dataContentDto->setDataContentData($dataContentEntity->getDataContentData()); return $dataContentDto; } else { return null; } }
foreach ($dataContentListDto->getDataContents() as $dataContentDto) { $dataContentEntity = bindDataContentDto($dataContentDto); $entityManager->persist($dataContentEntity); $entityManager->flush(); } }); $app->put('/datacontents/:id', function ($id) use($app) { global $entityManager; $dataContentEntity = $entityManager->find("DataContentEntity", $id); $entityManager->flush(); $dataContentDto = bindDataContentEntity($dataContentEntity); $dataContentDto->printData($app); }); $app->post('/datacontents', function () use($app) { global $entityManager; $dataContentDto = new DataContentDto(); $dataContentDto->bindJson($app); $entityManager->persist($dataContentEntity); $entityManager->flush(); $dataContentDto = bindDataContentEntity($dataContentEntity); $dataContentDto->printData($app); }); $app->delete('/datacontents/:id', function ($id) use($app) { global $entityManager; $dataContentEntity = $entityManager->find("DataContentEntity", $id); $entityManager->remove($dataContentEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/datacontents/:id/newss', function ($id) use($app) { global $entityManager;