ticketUtils = $utilsManager->getTicketUtils(); parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator); } /** * The method that is executed when the user performs a 'show' action on an entity. * * @return Response */ public function renderTicketTemplate($actionName, $templatePath, array $parameters = []) { if ($actionName == 'show') { $parameters['form_add_ticket_message'] = $this->createCustomForm(TicketMessageType::class, 'newMessageTicket', $parameters, false)->createView(); $parameters['form_ticket_status'] = $this->createCustomForm(TicketStatusType::class, 'ticketStatus', $parameters)->createView(); } return parent::renderTemplate($actionName, $templatePath, $parameters); } public function ticketStatusAction(){ $easyadmin = $this->request->attributes->get('easyadmin'); $ticket = $easyadmin['item']; $formTicketStatusForm = $this->createForm(TicketStatusType::class, $ticket); $formTicketStatusForm->handleRequest($this->request); if ($formTicketStatusForm->isSubmitted() && $formTicketStatusForm->isValid()) { $this->em->persist($ticket); $this->em->flush(); $this->utils->addFlash('success', 'success.ticket.statusChange'); } else { $this->utils->addFlash('error', $formTicketStatusForm->getErrors()); } $response['flashMessages'] = $this->utils->getFlashMessages(); return new Response(json_encode($response)); } public function newMessageTicketAction(){ $easyadmin = $this->request->attributes->get('easyadmin'); $ticket = $easyadmin['item']; $formAddTicketMessage = $this->createForm(TicketMessageType::class); $formAddTicketMessage->handleRequest($this->request); if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) { $this->ticketUtils->createTicketMessage(array( 'ticket'=>$ticket, 'message'=> $formAddTicketMessage->get('message')->getData(), 'answerByAdmin'=>true )); $this->utils->addFlash('success', 'success.ticket.addMessage'); } else { $this->utils->addFlash('error', $formAddTicketMessage->getErrors()); } return $this->redirectToRoute('easyadmin', [ 'action' => 'show', 'entity' => 'Ticket', 'id' => $ticket->getId() ]); } }