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.

ReminderStore.php 2.8KB

3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace Lc\SovBundle\Repository\Reminder;
  3. use Lc\SovBundle\Model\User\UserInterface;
  4. use Lc\SovBundle\Repository\AbstractStore;
  5. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  6. class ReminderStore extends AbstractStore implements ReminderStoreInterface
  7. {
  8. protected ReminderRepositoryQueryInterface $query;
  9. public function __construct(ReminderRepositoryQueryInterface $query)
  10. {
  11. $this->query = $query;
  12. }
  13. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  14. {
  15. $query->orderBy('id');
  16. return $query;
  17. }
  18. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  19. {
  20. return $query;
  21. }
  22. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  23. {
  24. return $query;
  25. }
  26. public function get($params = [], $query = null)
  27. {
  28. $query = $this->createDefaultQuery($query);
  29. $query->filterByDone();
  30. if (array_key_exists('user', $params)) {
  31. $query
  32. ->filterByUser($params['user'])
  33. ->groupBy('.id');
  34. }
  35. if (array_key_exists('crudAction', $params)) {
  36. $query->filterByCrudAction($params['crudAction']);
  37. }
  38. if (array_key_exists('crudControllerFqcn', $params)) {
  39. $query->filterByCrudControllerFqcn($params['crudControllerFqcn']);
  40. }
  41. if (array_key_exists('entityId', $params)) {
  42. $query->filterByEntityId($params['entityId']);
  43. }
  44. $query->orderBy('.dateReminder');
  45. return $query->find();
  46. }
  47. // findByUser
  48. public function getByUser(UserInterface $user, $query = null): array
  49. {
  50. $query = $this->createDefaultQuery($query);
  51. $query = $this->query->create();
  52. $query
  53. ->filterByUser($user)
  54. ->filterIsNotDone()
  55. ->orderBy('.dateReminder')
  56. ->groupBy('.id');
  57. return $query->find();
  58. }
  59. // findByEasyAdminConfigAndUser
  60. public function getByEasyAdminConfigAndUser(
  61. string $crudAction,
  62. string $crudControllerFqcn,
  63. UserInterface $user,
  64. int $entityId = null,
  65. $query = null
  66. ): array {
  67. $query = $this->createDefaultQuery($query);
  68. $query
  69. ->filterByUser($user)
  70. ->filterLikeCrudAction($crudAction)
  71. ->filterLikeCrudControllerFqcn($crudControllerFqcn)
  72. ->filterIsNotDone();
  73. if ($entityId) {
  74. $query
  75. ->filterLikeEntityId($entityId);
  76. }
  77. $query
  78. ->orderBy('.dateReminder')
  79. ->groupBy('.id');
  80. return $query->find();
  81. }
  82. }