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.

80 lines
2.3KB

  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 get($params = [], $query = null)
  11. {
  12. if(is_null($query)) {
  13. $query = $this->query->create();
  14. }
  15. $query->filterDone();
  16. if(array_key_exists('user', $params)) {
  17. $query->filterUser($params['user']);
  18. }
  19. if(array_key_exists('crudAction', $params)) {
  20. $query->filterCrudAction($params['crudAction']);
  21. }
  22. if(array_key_exists('crudControllerFqcn', $params)) {
  23. $query->filterCrudControllerFqcn($params['crudControllerFqcn']);
  24. }
  25. if(array_key_exists('entityId', $params)) {
  26. $query->filterEntityId($params['entityId']);
  27. }
  28. $query->orderDefault();
  29. return $query->find();
  30. }
  31. /*
  32. public function findByUser($user)
  33. {
  34. $qb = $this->createQueryBuilder('e')
  35. ->leftJoin('e.users', 'u')
  36. ->having('COUNT(u.id) = 0')
  37. ->orHaving(':user MEMBER OF e.users')
  38. ->andWhere('e.done = 0')
  39. ->setParameter('user', $user)
  40. ->orderBy('e.dateReminder', 'ASC')
  41. ->groupBy('e.id');
  42. return $qb->getQuery()->getResult();
  43. }
  44. public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
  45. {
  46. $qb = $this->createQueryBuilder('e');
  47. $qb->leftJoin('e.users', 'u');
  48. $qb->having('COUNT(u.id) = 0');
  49. $qb->orHaving(':user MEMBER OF e.users');
  50. $qb->andWhere('e.done = 0');
  51. $qb->andWhere('e.crudAction LIKE :crudAction');
  52. $qb->andWhere('e.crudControllerFqcn LIKE :entity');
  53. $qb->setParameter('crudAction', $crudAction);
  54. $qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
  55. $qb->setParameter('user', $user);
  56. if ($entityId) {
  57. $qb->andWhere('e.entityId LIKE :id');
  58. $qb->setParameter('entityId', $entityId);
  59. }
  60. $qb->orderBy('e.dateReminder', 'ASC');
  61. $qb->groupBy('e.id');
  62. return $qb->getQuery()->getResult();
  63. }*/
  64. }