Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

getDoctrine

//use EntityManagerInterface
public function delete(Request $request, Test $test, EntityManagerInterface $entityManager): Response
{
    if ($this->isCsrfTokenValid('delete'.$test->getId(), $request->request->get('_token'))) {
        $entityManager->remove($test);
        $entityManager->flush();
    }

    return $this->redirectToRoute('test_index', [], Response::HTTP_SEE_OTHER);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #getDoctrine
ADD COMMENT
Topic
Name
5+1 =