Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

78 lines
2.2KB

  1. <?php
  2. namespace Lc\SovBundle\Solver\Ticket;
  3. use Lc\SovBundle\Model\Ticket\TicketInterface;
  4. use Lc\SovBundle\Model\Ticket\TicketModel;
  5. class TicketSolver
  6. {
  7. public function getTypeChoices($context = 'backend'): array
  8. {
  9. return [
  10. TicketModel::TYPE_GENERAL_QUESTION,
  11. TicketModel::TYPE_TECHNICAL_PROBLEM,
  12. ];
  13. }
  14. public static function getStatusChoices(): array
  15. {
  16. return [
  17. TicketModel::TICKET_STATUS_OPEN,
  18. TicketModel::TICKET_STATUS_BEING_PROCESSED,
  19. TicketModel::TICKET_STATUS_PROCESSED,
  20. TicketModel::TICKET_STATUS_CLOSED,
  21. ];
  22. }
  23. public function getTypeLabel(TicketInterface $ticket): string
  24. {
  25. return 'entity.Ticket.fields.typeChoices.'.$ticket->getType();
  26. }
  27. public function getStatusLabel(TicketInterface $ticket): string
  28. {
  29. return 'entity.Ticket.fields.statusChoices.'.$ticket->getStatus();
  30. }
  31. public function getUsername(TicketInterface $ticket)
  32. {
  33. if ($ticket->getUser()) {
  34. return $ticket->getUser()->getName();
  35. } else {
  36. return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname();
  37. }
  38. }
  39. public function getUserInfosTicket(TicketInterface $ticket)
  40. {
  41. $user = $ticket->getUser();
  42. if ($user) {
  43. return '#'.$user->getId().' '.$user->getFirstname().' '.$user->getLastname(). ' '.$user->getEmail();
  44. } else {
  45. return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail(
  46. );
  47. }
  48. }
  49. public function getEmail(TicketInterface $ticket)
  50. {
  51. if ($ticket->getUser()) {
  52. return $ticket->getUser()->getEmail();
  53. } else {
  54. return $ticket->getVisitorEmail();
  55. }
  56. }
  57. public function getVisitorInfos(TicketInterface $ticket)
  58. {
  59. return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' ('.$ticket->getVisitorEmail(
  60. ).')';
  61. }
  62. public function getLastMessage(TicketInterface $ticket)
  63. {
  64. return $ticket->getTicketMessages()->last();
  65. }
  66. }