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.

58 lines
1.3KB

  1. <?php
  2. namespace Lc\SovBundle\Repository\Ticket;
  3. use App\Entity\Ticket\Ticket;
  4. use Lc\SovBundle\Model\Ticket\TicketInterface;
  5. use Lc\SovBundle\Repository\AbstractStore;
  6. class TicketStore extends AbstractStore implements TicketStoreInterface
  7. {
  8. protected TicketRepositoryQueryInterface $query;
  9. public function __construct(TicketRepositoryQueryInterface $query)
  10. {
  11. $this->query = $query;
  12. }
  13. // getTicketsByUser
  14. public function getByUser($user, $query = null): array
  15. {
  16. if (is_null($query)) {
  17. $query = $this->query->create();
  18. }
  19. $query->filterByUser($user);
  20. return $query->find();
  21. }
  22. // findAllOpen
  23. public function getOpen(int $limit = 0, $query = null): array
  24. {
  25. if (is_null($query)) {
  26. $query = $this->query->create();
  27. }
  28. $query
  29. ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
  30. ->limit($limit)
  31. ->orderBy('r.id', 'DESC');
  32. return $query->find();
  33. }
  34. // countAllOpen
  35. public function countOpen($query = null): string
  36. {
  37. if (is_null($query)) {
  38. $query = $this->query->create();
  39. }
  40. $query
  41. ->selectCount()
  42. ->filterByStatus(Ticket::TICKET_STATUS_OPEN);
  43. return $query->count();
  44. }
  45. }