function bindTransactionEntity($transactionEntity) { if ($transactionEntity != null) { $transactionDto = new TransactionDto(); $transactionDto->setTransactionId($transactionEntity->getTransactionId()); $transactionDto->setTransactionTotal($transactionEntity->getTransactionTotal()); $transactionDto->setUser(bindUserEntity($transactionEntity->getUser())); $transactionDto->setTransactionType($transactionEntity->getTransactionType()); $transactionDto->setTransactionProof(bindTransactionProofEntity($transactionEntity->getTransactionProof())); $transactionDto->setTransactionDate($transactionEntity->getTransactionDate()); return $transactionDto; } else { return null; } }
foreach ($transactionListDto->getTransactions() as $transactionDto) { $transactionEntity = bindTransactionDto($transactionDto); $entityManager->persist($transactionEntity); $entityManager->flush(); } }); $app->put('/transactions/:id', function ($id) use($app) { global $entityManager; $transactionEntity = $entityManager->find("TransactionEntity", $id); $entityManager->flush(); $transactionDto = bindTransactionEntity($transactionEntity); $transactionDto->printData($app); }); $app->post('/transactions', function () use($app) { global $entityManager; $transactionDto = new TransactionDto(); $transactionDto->bindJson($app); $entityManager->persist($transactionEntity); $entityManager->flush(); $transactionDto = bindTransactionEntity($transactionEntity); $transactionDto->printData($app); }); $app->delete('/transactions/:id', function ($id) use($app) { global $entityManager; $transactionEntity = $entityManager->find("TransactionEntity", $id); $entityManager->remove($transactionEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/transactions/:id/transactionservices', function ($id) use($app) { global $entityManager;