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 1.8KB

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. }