ticketUtils = $utilsManager->getTicketUtils(); parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator); } protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) { $queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); if ($this->filtersForm->get('status')->getData() === null) { $queryBuilder->andWhere('entity.status LIKE :open OR entity.status LIKE :beingprocessed'); $queryBuilder->setParameter('open', Ticket::TICKET_STATUS_OPEN); $queryBuilder->setParameter('beingprocessed', Ticket::TICKET_STATUS_BEING_PROCESSED); } return $queryBuilder; } public function showAction() { $this->dispatch(EasyAdminEvents::PRE_SHOW); $id = $this->request->query->get('id'); $easyadmin = $this->request->attributes->get('easyadmin'); $entity = $easyadmin['item']; $fields = $this->entity['show']['fields']; $deleteForm = $this->createDeleteForm($this->entity['name'], $id); $this->dispatch(EasyAdminEvents::POST_SHOW, [ 'deleteForm' => $deleteForm, 'fields' => $fields, 'entity' => $entity, ]); $parameters = [ 'entity' => $entity, 'fields' => $fields, 'delete_form' => $deleteForm->createView(), ]; return $this->executeDynamicMethod('renderTemplate', ['show', $this->entity['templates']['show'], $parameters]); } /** * 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() ]); } }