public function deleteAction(
        string $production_slug,
        int $id,
        AuthorizationCheckerInterface $auth,
        Request $request
    ): Response {
        // Get the schedule and production for this action.
        list($schedule, $production) = $this->lookupEntity(Schedule::class, $id, $production_slug);

        // Check permissions for this action.
        if (!$auth->isGranted('edit', $schedule)) {
            throw new AccessDeniedException();
        }

        // Create and handle a fake form to submit.
        $form = $this->form->createBuilder()->getForm();
        $form->handleRequest($request);

        // If form is submitted and valid.
        if ($form->isSubmitted() && $form->isValid()) {
            // Remove the schedule and flush the entity manager.
            $this->em->remove($schedule);
            $this->em->flush();

            // Create flash message.
            $this->session->getFlashBag()->add(
                'success',
                $this->translator->trans('schedule.deleted', [
                    '%schedule%' => $schedule->getName(),
                ], BkstgScheduleBundle::TRANSLATION_DOMAIN)
            );

            // Redirect to production calendar.
            return new RedirectResponse($this->url_generator->generate(
                'bkstg_calendar_production',
                ['production_slug' => $production->getSlug()]
            ));
        }

        // Render the delete form.
        return new Response($this->templating->render('@BkstgSchedule/Schedule/delete.html.twig', [
            'schedule' => $schedule,
            'production' => $production,
            'form' => $form->createView(),
        ]));
    }
public function deleteAction(
        string $production_slug,
        int $id,
        AuthorizationCheckerInterface $auth,
        Request $request
    ): Response {
        // Get the schedule and production for this action.
        list($schedule, $production) = $this->lookupEntity(Schedule::class, $id, $production_slug);

        // Check permissions for this action.
        if (!$auth->isGranted('edit', $schedule)) {
            throw new AccessDeniedException();
        }

        // Create and handle a fake form to submit.
        $form = $this->form->createBuilder()->getForm();
        $form->handleRequest($request);

        // If form is submitted and valid.
        if ($form->isSubmitted() && $form->isValid()) {
            // Remove the schedule and flush the entity manager.
            $this->em->remove($schedule);
            $this->em->flush();

            // Create flash message.
            $this->session->getFlashBag()->add(
                'success',
                $this->translator->trans('schedule.deleted', [
                    '%schedule%' => $schedule->getName(),
                ], BkstgScheduleBundle::TRANSLATION_DOMAIN)
            );

            // Redirect to production calendar.
            return new RedirectResponse($this->url_generator->generate(
                'bkstg_calendar_production',
                ['production_slug' => $production->getSlug()]
            ));
        }

        // Render the delete form.
        return new Response($this->templating->render('@BkstgSchedule/Schedule/delete.html.twig', [
            'schedule' => $schedule,
            'production' => $production,
            'form' => $form->createView(),
        ]));
    }
public function deleteAction ( string $ production_slug , int $ id , AuthorizationCheckerInterface $ auth , Request $ request ) : Response { // Get the schedule and production for this action. list ( $ schedule , $ production ) = $ this -> lookupEntity ( Schedule :: class , $ id , $ production_slug ) ; // Check permissions for this action. if ( ! $ auth -> isGranted ( 'edit' , $ schedule ) ) { throw new AccessDeniedException ( ) ; } // Create and handle a fake form to submit. $ form = $ this -> form -> createBuilder ( ) -> getForm ( ) ; $ form -> handleRequest ( $ request ) ; // If form is submitted and valid. if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { // Remove the schedule and flush the entity manager. $ this -> em -> remove ( $ schedule ) ; $ this -> em -> flush ( ) ; // Create flash message. $ this -> session -> getFlashBag ( ) -> add ( 'success' , $ this -> translator -> trans ( 'schedule.deleted' , [ '%schedule%' => $ schedule -> getName ( ) , ] , BkstgScheduleBundle :: TRANSLATION_DOMAIN ) ) ; // Redirect to production calendar. return new RedirectResponse ( $ this -> url_generator -> generate ( 'bkstg_calendar_production' , [ 'production_slug' => $ production -> getSlug ( ) ] ) ) ; } // Render the delete form. return new Response ( $ this -> templating -> render ( '@BkstgSchedule/Schedule/delete.html.twig' , [ 'schedule' => $ schedule , 'production' => $ production , 'form' => $ form -> createView ( ) , ] ) ) ; }
Delete a single schedule.

@param string                        $production_slug The production slug.
@param int                           $id              The schedule id.
@param AuthorizationCheckerInterface $auth            The authorization checker service.
@param Request                       $request         The incoming request.

@throws AccessDeniedException If the user has no access to edit.

@return Response
Delete a single schedule .