vendor/uvdesk/core-framework/Controller/TeamXHR.php line 26

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Controller;
  3. use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  8. use Webkul\UVDesk\CoreFrameworkBundle\Services\UserService;
  9. use Symfony\Contracts\Translation\TranslatorInterface;
  10. use Symfony\Component\DependencyInjection\ContainerInterface;
  11. use Webkul\UVDesk\CoreFrameworkBundle\Entity\SupportTeam;
  12. class TeamXHR extends AbstractController
  13. {
  14.     private $userService;
  15.     private $translator;
  16.     
  17.     public function __construct(UserService $userServiceTranslatorInterface $translator)
  18.     {
  19.         $this->userService $userService;
  20.         $this->translator $translator;
  21.     }
  22.     public function listTeamsXHR(Request $requestContainerInterface $container)
  23.     {
  24.         if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_SUB_GROUP')){
  25.             return $this->redirect($this->generateUrl('helpdesk_member_dashboard'));
  26.         }
  27.         if (true === $request->isXmlHttpRequest()) {
  28.             $paginationResponse $this->getDoctrine()->getRepository(SupportTeam::class)->getAllSupportTeams($request->query$container);
  29.             return new Response(json_encode($paginationResponse), 200, ['Content-Type' => 'application/json']);
  30.         }
  31.         return new Response(json_encode([]), 404, ['Content-Type' => 'application/json']);
  32.     }
  33.     public function deleteTeamXHR($supportTeamIdTranslatorInterface $translator)
  34.     {
  35.         if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_SUB_GROUP')){
  36.             return $this->redirect($this->generateUrl('helpdesk_member_dashboard'));
  37.         }
  38.         $request $this->container->get('request_stack')->getCurrentRequest();
  39.         if ("DELETE" == $request->getMethod()) {
  40.             $entityManager $this->getDoctrine()->getManager();
  41.             $supportTeam $entityManager->getRepository(SupportTeam::class)->findOneById($supportTeamId);
  42.             if (!empty($supportTeam)) {
  43.                 $entityManager->remove($supportTeam);
  44.                 $entityManager->flush();
  45.                 
  46.                 return new Response(json_encode([
  47.                     'alertClass' => 'success',
  48.                     'alertMessage' => $this->translator->trans('Support Team removed successfully.'),
  49.                 ]), 200, ['Content-Type' => 'application/json']);
  50.             }
  51.         }
  52.         return new Response(json_encode([]), 404, ['Content-Type' => 'application/json']);
  53.     }
  54. }