$serviceEntity = bindServiceDto($serviceDto); $entityManager->persist($serviceEntity); $entityManager->flush(); } }); $app->put('/services/:id', function ($id) use($app) { global $entityManager; $serviceEntity = $entityManager->find("ServiceEntity", $id); $entityManager->flush(); $serviceDto = bindServiceEntity($serviceEntity); $serviceDto->printData($app); }); $app->post('/services', function () use($app) { global $entityManager; $serviceDto = new ServiceDto(); $serviceDto->bindJson($app); $entityManager->persist($serviceEntity); $entityManager->flush(); $serviceDto = bindServiceEntity($serviceEntity); $serviceDto->printData($app); }); $app->delete('/services/:id', function ($id) use($app) { global $entityManager; $serviceEntity = $entityManager->find("ServiceEntity", $id); $entityManager->remove($serviceEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/services/:id/transactionservices', function ($id) use($app) { global $entityManager; $transactionServiceEntities = $entityManager->getRepository("TransactionServiceEntity")->findBy(array('service' => $id));