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

        // If this event is handled by a schedule redirect there.
        if (null !== $redirect = $this->checkSchedule($event, $production)) {
            return $redirect;
        }

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

        // Create an index of invitations for checking later.
        $invitations = new ArrayCollection();
        foreach ($event->getInvitations() as $invitation) {
            $invitations->add($invitation);
        }

        // Create and handle the form.
        $form = $this->form->create(EventType::class, $event);
        $form->handleRequest($request);

        // If the form is submitted and valid persist the event.
        if ($form->isSubmitted() && $form->isValid()) {
            // Remove unneeded invitations.
            foreach ($invitations as $invitation) {
                if (false === $event->getInvitations()->contains($invitation)) {
                    $this->em->remove($invitation);
                }
            }

            $this->em->persist($event);
            $this->em->flush();

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

            return new RedirectResponse($this->url_generator->generate(
                'bkstg_event_read',
                ['id' => $event->getId(), 'production_slug' => $production->getSlug()]
            ));
        }

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

        // If this event is handled by a schedule redirect there.
        if (null !== $redirect = $this->checkSchedule($event, $production)) {
            return $redirect;
        }

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

        // Create an index of invitations for checking later.
        $invitations = new ArrayCollection();
        foreach ($event->getInvitations() as $invitation) {
            $invitations->add($invitation);
        }

        // Create and handle the form.
        $form = $this->form->create(EventType::class, $event);
        $form->handleRequest($request);

        // If the form is submitted and valid persist the event.
        if ($form->isSubmitted() && $form->isValid()) {
            // Remove unneeded invitations.
            foreach ($invitations as $invitation) {
                if (false === $event->getInvitations()->contains($invitation)) {
                    $this->em->remove($invitation);
                }
            }

            $this->em->persist($event);
            $this->em->flush();

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

            return new RedirectResponse($this->url_generator->generate(
                'bkstg_event_read',
                ['id' => $event->getId(), 'production_slug' => $production->getSlug()]
            ));
        }

        // Render the form.
        return new Response($this->templating->render('@BkstgSchedule/Event/update.html.twig', [
            'event' => $event,
            'production' => $production,
            'form' => $form->createView(),
        ]));
    }
public function updateAction ( string $ production_slug , int $ id , AuthorizationCheckerInterface $ auth , TokenStorageInterface $ token , Request $ request ) : Response { // Get the event and production for this action. list ( $ event , $ production ) = $ this -> lookupEntity ( Event :: class , $ id , $ production_slug ) ; // If this event is handled by a schedule redirect there. if ( null !== $ redirect = $ this -> checkSchedule ( $ event , $ production ) ) { return $ redirect ; } // Check permissions for this action. if ( ! $ auth -> isGranted ( 'edit' , $ event ) ) { throw new AccessDeniedException ( ) ; } // Create an index of invitations for checking later. $ invitations = new ArrayCollection ( ) ; foreach ( $ event -> getInvitations ( ) as $ invitation ) { $ invitations -> add ( $ invitation ) ; } // Create and handle the form. $ form = $ this -> form -> create ( EventType :: class , $ event ) ; $ form -> handleRequest ( $ request ) ; // If the form is submitted and valid persist the event. if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { // Remove unneeded invitations. foreach ( $ invitations as $ invitation ) { if ( false === $ event -> getInvitations ( ) -> contains ( $ invitation ) ) { $ this -> em -> remove ( $ invitation ) ; } } $ this -> em -> persist ( $ event ) ; $ this -> em -> flush ( ) ; // Set success message and redirect. $ this -> session -> getFlashBag ( ) -> add ( 'success' , $ this -> translator -> trans ( 'event.updated' , [ '%event%' => $ event -> getName ( ) , ] , BkstgScheduleBundle :: TRANSLATION_DOMAIN ) ) ; return new RedirectResponse ( $ this -> url_generator -> generate ( 'bkstg_event_read' , [ 'id' => $ event -> getId ( ) , 'production_slug' => $ production -> getSlug ( ) ] ) ) ; } // Render the form. return new Response ( $ this -> templating -> render ( '@BkstgSchedule/Event/update.html.twig' , [ 'event' => $ event , 'production' => $ production , 'form' => $ form -> createView ( ) , ] ) ) ; }
Update a standalone event.

@param string                        $production_slug The slug for the production.
@param int                           $id              The event id.
@param AuthorizationCheckerInterface $auth            The authorization checker service.
@param TokenStorageInterface         $token           The token storage service.
@param Request                       $request         The request.

@throws AccessDeniedException When the user is not an editor.

@return Response The response.
Update a standalone event .