Controller/Product/ProductAdminController.php
public function deleteAction($id)
    {
        $product = $this->container->get('vespolina.product_manager')->findProductById($id);

        if (!$product) {
            throw new NotFoundHttpException('The product does not exist!');
        }

        $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
        $dm->remove($product);
        $dm->flush();

        $this->setFlash('vespolina_product_deleted', 'success');
        $url = $this->container->get('router')->generate('vespolina_product_list');
        return new RedirectResponse($url);
    }
public function deleteAction($id)
    {
        $product = $this->container->get('vespolina.product_manager')->findProductById($id);

        if (!$product) {
            throw new NotFoundHttpException('The product does not exist!');
        }

        $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
        $dm->remove($product);
        $dm->flush();

        $this->setFlash('vespolina_product_deleted', 'success');
        $url = $this->container->get('router')->generate('vespolina_product_list');
        return new RedirectResponse($url);
    }
public function deleteAction ( $ id ) { $ product = $ this -> container -> get ( 'vespolina.product_manager' ) -> findProductById ( $ id ) ; if ( ! $ product ) { throw new NotFoundHttpException ( 'The product does not exist!' ) ; } $ dm = $ this -> container -> get ( 'doctrine.odm.mongodb.document_manager' ) ; $ dm -> remove ( $ product ) ; $ dm -> flush ( ) ; $ this -> setFlash ( 'vespolina_product_deleted' , 'success' ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'vespolina_product_list' ) ; return new RedirectResponse ( $ url ) ; }
Delete one product, then show list
Delete one product then show list