Controller/TicketController.php
public function deleteAction(Request $request, $ticketId)
    {
        $userManager = $this->getUserManager();
        $user        = $userManager->getCurrentUser();

        if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) {
            throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
        }

        $form = $this->createDeleteForm($ticketId);

        if ($request->isMethod('DELETE')) {
            $form->submit($request->request->get($form->getName()));

            if ($form->isValid()) {
                $ticketManager = $this->get('hackzilla_ticket.ticket_manager');
                $ticket        = $ticketManager->getTicketById($ticketId);

                if (!$ticket) {
                    throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
                }

                $ticketManager->deleteTicket($ticket);
                $this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket);
            }
        }

        return $this->redirect($this->generateUrl('hackzilla_ticket'));
    }
public function deleteAction(Request $request, $ticketId)
    {
        $userManager = $this->getUserManager();
        $user        = $userManager->getCurrentUser();

        if (!\is_object($user) || !$userManager->hasRole($user, TicketRole::ADMIN)) {
            throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
        }

        $form = $this->createDeleteForm($ticketId);

        if ($request->isMethod('DELETE')) {
            $form->submit($request->request->get($form->getName()));

            if ($form->isValid()) {
                $ticketManager = $this->get('hackzilla_ticket.ticket_manager');
                $ticket        = $ticketManager->getTicketById($ticketId);

                if (!$ticket) {
                    throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
                }

                $ticketManager->deleteTicket($ticket);
                $this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket);
            }
        }

        return $this->redirect($this->generateUrl('hackzilla_ticket'));
    }
public function deleteAction ( Request $ request , $ ticketId ) { $ userManager = $ this -> getUserManager ( ) ; $ user = $ userManager -> getCurrentUser ( ) ; if ( ! \ is_object ( $ user ) || ! $ userManager -> hasRole ( $ user , TicketRole :: ADMIN ) ) { throw new \ Symfony \ Component \ HttpKernel \ Exception \ HttpException ( 403 ) ; } $ form = $ this -> createDeleteForm ( $ ticketId ) ; if ( $ request -> isMethod ( 'DELETE' ) ) { $ form -> submit ( $ request -> request -> get ( $ form -> getName ( ) ) ) ; if ( $ form -> isValid ( ) ) { $ ticketManager = $ this -> get ( 'hackzilla_ticket.ticket_manager' ) ; $ ticket = $ ticketManager -> getTicketById ( $ ticketId ) ; if ( ! $ ticket ) { throw $ this -> createNotFoundException ( $ this -> get ( 'translator' ) -> trans ( 'ERROR_FIND_TICKET_ENTITY' , [ ] , 'HackzillaTicketBundle' ) ) ; } $ ticketManager -> deleteTicket ( $ ticket ) ; $ this -> dispatchTicketEvent ( TicketEvents :: TICKET_DELETE , $ ticket ) ; } } return $ this -> redirect ( $ this -> generateUrl ( 'hackzilla_ticket' ) ) ; }
Deletes a Ticket entity.

@param Request $request
@param int     $ticketId

@return \Symfony\Component\HttpFoundation\RedirectResponse
Deletes a Ticket entity .