src/PN/Bundle/ProductBundle/Controller/Administration/OccasionController.php
/**
     * Remove all product from occasion entity.
     *
     * @Route("/clear-product/{id}", name="occasion_clear_products", methods={"POST"})
     */
Remove all product from occasion entity.
Remove all product from occasion entity .
public function clearProductAction(Request $request, Occasion $occasion)
    {
        $this->denyAccessUnlessGranted(['ROLE_ADMIN', 'ROLE_MANAGE_PRODUCTS']);
        $em = $this->getDoctrine()->getManager();
        $em->getRepository(ProductHasOccasion::class)->removeProductByOccasion($occasion);
        return $this->redirectToRoute('occasion_index');
    }
public function clearProductAction ( Request $ request , Occasion $ occasion ) { $ this -> denyAccessUnlessGranted ( [ 'ROLE_ADMIN' , 'ROLE_MANAGE_PRODUCTS' ] ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> getRepository ( ProductHasOccasion :: class ) -> removeProductByOccasion ( $ occasion ) ; return $ this -> redirectToRoute ( 'occasion_index' ) ; }
Remove all product from occasion entity.
Remove all product from occasion entity .