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.

78 lines
2.1KB

  1. <?php
  2. namespace Lc\SovBundle\Repository\Reminder;
  3. class ReminderStore implements ReminderStoreInterface
  4. {
  5. protected ReminderRepositoryQueryInterface $query;
  6. public function __construct(ReminderRepositoryQueryInterface $query)
  7. {
  8. $this->query = $query;
  9. }
  10. public function getByUser($user)
  11. {
  12. $query = $this->query->create();
  13. return $query
  14. ->filterDone()
  15. ->filterUser($user)
  16. ->orderDefault()
  17. ->find();
  18. }
  19. /*public function getFoo($query = null)
  20. {
  21. if (!$query) {
  22. $query = $this->query->create();
  23. }
  24. return $query
  25. ->useCustomFilters()
  26. ->andWhere('.description = :description')
  27. ->setParameter(':description', 'ahah')
  28. ->findOne();
  29. }*/
  30. /*
  31. public function findByUser($user)
  32. {
  33. $qb = $this->createQueryBuilder('e')
  34. ->leftJoin('e.users', 'u')
  35. ->having('COUNT(u.id) = 0')
  36. ->orHaving(':user MEMBER OF e.users')
  37. ->andWhere('e.done = 0')
  38. ->setParameter('user', $user)
  39. ->orderBy('e.dateReminder', 'ASC')
  40. ->groupBy('e.id');
  41. return $qb->getQuery()->getResult();
  42. }
  43. public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
  44. {
  45. $qb = $this->createQueryBuilder('e');
  46. $qb->leftJoin('e.users', 'u');
  47. $qb->having('COUNT(u.id) = 0');
  48. $qb->orHaving(':user MEMBER OF e.users');
  49. $qb->andWhere('e.done = 0');
  50. $qb->andWhere('e.crudAction LIKE :crudAction');
  51. $qb->andWhere('e.crudControllerFqcn LIKE :entity');
  52. $qb->setParameter('crudAction', $crudAction);
  53. $qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
  54. $qb->setParameter('user', $user);
  55. if ($entityId) {
  56. $qb->andWhere('e.entityId LIKE :id');
  57. $qb->setParameter('entityId', $entityId);
  58. }
  59. $qb->orderBy('e.dateReminder', 'ASC');
  60. $qb->groupBy('e.id');
  61. return $qb->getQuery()->getResult();
  62. }
  63. */
  64. }