You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TicketStore.php 2.1KB

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Lc\SovBundle\Repository\Ticket;
  3. use App\Entity\Ticket\Ticket;
  4. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  5. use Lc\SovBundle\Model\Ticket\TicketInterface;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\SovBundle\Repository\AbstractStore;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. class TicketStore extends AbstractStore implements TicketStoreInterface
  10. {
  11. protected TicketRepositoryQueryInterface $query;
  12. public function __construct(TicketRepositoryQueryInterface $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('updatedAt', 'DESC');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. return $query;
  24. }
  25. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  26. {
  27. return $query;
  28. }
  29. // getTicketsByUser
  30. public function getByUser(UserInterface $user, $query = null): array
  31. {
  32. $query = $this->createDefaultQuery($query);
  33. $query->filterByUser($user);
  34. return $query->find();
  35. }
  36. // findAllOpen
  37. public function getOpen(int $limit = 0, $query = null): array
  38. {
  39. $query = $this->createDefaultQuery($query);
  40. $query
  41. ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
  42. ->limit($limit)
  43. ->orderBy('.id', 'DESC');
  44. return $query->find();
  45. }
  46. // countAllOpen
  47. public function countOpen($query = null): string
  48. {
  49. $query = $this->createDefaultQuery($query);
  50. $query
  51. ->selectCount()
  52. ->filterByStatus(Ticket::TICKET_STATUS_OPEN);
  53. return $query->count();
  54. }
  55. public function getOneByIdAndVisitorToken(int $id, string $token, $query = null)
  56. {
  57. $query = $this->createDefaultQuery($query);
  58. $query
  59. ->filterById($id)
  60. ->filterByVisitorToken($token);
  61. return $query->findOne();
  62. }
  63. }