vendor/uvdesk/core-framework/Controller/ThreadXHR.php line 20

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Webkul\UVDesk\CoreFrameworkBundle\Services\TicketService;
  7. use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket;
  8. class ThreadXHR extends AbstractController
  9. {
  10. private $ticketService;
  11. public function __construct(TicketService $ticketService)
  12. {
  13. $this->ticketService = $ticketService;
  14. }
  15. public function listTicketThreadCollectionXHR($ticketId)
  16. {
  17. $entityManager = $this->getDoctrine()->getManager();
  18. $request = $this->container->get('request_stack')->getCurrentRequest();
  19. if (true === $request->isXmlHttpRequest()) {
  20. $ticket = $entityManager->getRepository(Ticket::class)->findOneById($ticketId);
  21. if (!empty($ticket)) {
  22. $paginationResponse = $this->ticketService->paginateMembersTicketThreadCollection($ticket, $request);
  23. return new Response(json_encode($paginationResponse), 200, ['Content-Type' => 'application/json']);
  24. }
  25. }
  26. return new Response(json_encode([]), 404, ['Content-Type' => 'application/json']);
  27. }
  28. }