/** * delete stock entity from the product detail table * @Route("/delete_stock/{id}",name="deletestock2") * @ParamConverter("stock", class="AppBundle:Stock") */ public function delete_stock(Stock $stock) { $client = $stock->getClient(); $client_id = $client->getId(); $em = $this->getDoctrine()->getManager(); $em->remove($stock); $em->flush(); if (count($client->getStocks()) == 0) { $client->setIfStockPurchased(false); $em->flush(); } return $this->redirectToRoute('productdetail', array('id' => $client_id)); }