public function deleteAction(
        int $id,
        Request $request
    ): Response {
        // Lookup the production by id.
        $production_repo = $this->em->getRepository(Production::class);
        if (null === $production = $production_repo->findOneBy(['id' => $id])) {
            throw new NotFoundHttpException();
        }

        // Create an empty form to submit.
        $form = $this->form->createBuilder()->getForm();
        $form->handleRequest($request);

        // Delete the production.
        if ($form->isSubmitted() && $form->isValid()) {
            $this->em->remove($production);
            $this->em->flush();

            // Set success message and redirect.
            $this->session->getFlashBag()->add(
                'success',
                $this->translator->trans('production.deleted', [
                    '%production%' => $production->getName(),
                ], BkstgCoreBundle::TRANSLATION_DOMAIN)
            );

            return new RedirectResponse($this->url_generator->generate('bkstg_production_admin_index'));
        }

        // Render the form.
        return new Response($this->templating->render('@BkstgCore/ProductionAdmin/delete.html.twig', [
            'production' => $production,
            'form' => $form->createView(),
        ]));
    }
public function deleteAction(
        int $id,
        Request $request
    ): Response {
        // Lookup the production by id.
        $production_repo = $this->em->getRepository(Production::class);
        if (null === $production = $production_repo->findOneBy(['id' => $id])) {
            throw new NotFoundHttpException();
        }

        // Create an empty form to submit.
        $form = $this->form->createBuilder()->getForm();
        $form->handleRequest($request);

        // Delete the production.
        if ($form->isSubmitted() && $form->isValid()) {
            $this->em->remove($production);
            $this->em->flush();

            // Set success message and redirect.
            $this->session->getFlashBag()->add(
                'success',
                $this->translator->trans('production.deleted', [
                    '%production%' => $production->getName(),
                ], BkstgCoreBundle::TRANSLATION_DOMAIN)
            );

            return new RedirectResponse($this->url_generator->generate('bkstg_production_admin_index'));
        }

        // Render the form.
        return new Response($this->templating->render('@BkstgCore/ProductionAdmin/delete.html.twig', [
            'production' => $production,
            'form' => $form->createView(),
        ]));
    }
public function deleteAction ( int $ id , Request $ request ) : Response { // Lookup the production by id. $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'id' => $ id ] ) ) { throw new NotFoundHttpException ( ) ; } // Create an empty form to submit. $ form = $ this -> form -> createBuilder ( ) -> getForm ( ) ; $ form -> handleRequest ( $ request ) ; // Delete the production. if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ this -> em -> remove ( $ production ) ; $ this -> em -> flush ( ) ; // Set success message and redirect. $ this -> session -> getFlashBag ( ) -> add ( 'success' , $ this -> translator -> trans ( 'production.deleted' , [ '%production%' => $ production -> getName ( ) , ] , BkstgCoreBundle :: TRANSLATION_DOMAIN ) ) ; return new RedirectResponse ( $ this -> url_generator -> generate ( 'bkstg_production_admin_index' ) ) ; } // Render the form. return new Response ( $ this -> templating -> render ( '@BkstgCore/ProductionAdmin/delete.html.twig' , [ 'production' => $ production , 'form' => $ form -> createView ( ) , ] ) ) ; }
Delete a production from the system.

@param int     $id      The id for the production.
@param Request $request The incoming Request.

@throws NotFoundHttpException When the production is not found.

@return Response The incoming response.
Delete a production from the system .