apps/uvdesk/custom-fields/src/Widgets/CustomFields.php line 40

Open in your IDE?
  1. <?php
  2. namespace UVDesk\CommunityPackages\UVDesk\CustomFields\Widgets;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Twig\Environment as TwigEnvironment;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. use Webkul\UVDesk\CoreFrameworkBundle\Tickets\WidgetInterface;
  7. use Webkul\UVDesk\CoreFrameworkBundle\Services\UserService;
  8. use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
  9. use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket;
  10. use Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance;
  11. use Webkul\UVDesk\CoreFrameworkBundle\Entity\SupportRole;
  12. use UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\CustomFields as CustomFieldsEntity;
  13. use UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\CustomFieldsValues;
  14. use UVDesk\CommunityPackages\UVDesk\CustomFields\Entity\TicketCustomFieldsValues;
  15. use UVDesk\CommunityPackages\UVDesk\CustomFields\Services\CustomFieldsService;
  16. class CustomFields implements WidgetInterface
  17. {
  18.     CONST SVG = <<<SVG
  19. <svg 
  20.  xmlns="http://www.w3.org/2000/svg"
  21.  xmlns:xlink="http://www.w3.org/1999/xlink"
  22.  width="20px" height="18px">
  23. <path fill-rule="evenodd"  fill="rgb(51, 51, 51)"
  24.  d="M15.000,14.000 L15.000,11.000 L17.000,11.000 L17.000,7.000 L15.000,7.000 L15.000,4.000 L20.000,4.000 L20.000,14.000 L15.000,14.000 ZM14.000,15.000 L16.000,15.000 L16.000,18.000 L9.000,18.000 L9.000,15.000 L11.000,15.000 L11.000,3.000 L9.000,3.000 L9.000,-0.000 L16.000,-0.000 L16.000,3.000 L14.000,3.000 L14.000,15.000 ZM10.000,7.000 L3.000,7.000 L3.000,11.000 L10.000,11.000 L10.000,14.000 L0.000,14.000 L0.000,4.000 L10.000,4.000 L10.000,7.000 Z"/>
  25. </svg>
  26. SVG;
  27.     public function __construct(RequestStack $requestStack,
  28.         TwigEnvironment $twig,
  29.         EntityManagerInterface $entityManager,
  30.         CustomFieldsService $customFieldsService,
  31.         UserService $userService
  32.     
  33.     {
  34.         $this->twig $twig;
  35.         $this->requestStack $requestStack;
  36.         $this->entityManager $entityManager;
  37.         $this->customFieldsService $customFieldsService;
  38.         $this->userService $userService;
  39.     }
  40.     public static function getIcon()
  41.     {
  42.         return self::SVG;
  43.     }
  44.     public static function getTitle()
  45.     {
  46.         return "Custom Fields";
  47.     }
  48.     public static function getDataTarget()
  49.     {
  50.         return 'uv-customfield-view';
  51.     }
  52.     public function getTemplate()
  53.     {   
  54.         $request $this->requestStack->getCurrentRequest();
  55.         $ticket $this->entityManager->getRepository(Ticket::class)->findOneById($request->attributes->get('ticketId'));
  56.         
  57.         if ($this->userService->getCurrentUser()->getCurrentInstance()->getSupportRole()->getCode() === 'ROLE_CUSTOMER') {
  58.             $ticket $this->entityManager->getRepository(Ticket::class)->findOneById($request->attributes->get('id'));
  59.             return $this->twig->render(
  60.                 '@_uvdesk_extension_uvdesk_custom_fields\widgets\CustomFields\customFieldSnippetCustomer.html.twig'
  61.                 $this->customFieldsService->getCustomerCustomFieldSnippet($ticket)
  62.             );
  63.         } else {
  64.             $ticket $this->entityManager->getRepository(Ticket::class)->findOneById($request->attributes->get('ticketId'));
  65.             
  66.             return $this->twig->render(
  67.                 '@_uvdesk_extension_uvdesk_custom_fields\widgets\CustomFields\customFieldSnippet.html.twig'
  68.                 $this->customFieldsService->getCustomFieldSnippet($ticket)
  69.             );
  70.         } 
  71.     }
  72. }