Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

103 linhas
2.7KB

  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
  52. ->filterByUser($user)
  53. ->filterIsNotDone()
  54. ->orderBy('.dateReminder')
  55. ->groupBy('.id');
  56. return $query->find();
  57. }
  58. // findByEasyAdminConfigAndUser
  59. public function getByEasyAdminConfigAndUser(
  60. string $crudAction,
  61. string $crudControllerFqcn,
  62. UserInterface $user,
  63. int $entityId = null,
  64. $query = null
  65. ): array {
  66. $query = $this->createDefaultQuery($query);
  67. $query
  68. ->filterByUser($user)
  69. ->filterLikeCrudAction($crudAction)
  70. ->filterLikeCrudControllerFqcn($crudControllerFqcn)
  71. ->filterIsNotDone();
  72. if ($entityId) {
  73. $query
  74. ->filterLikeEntityId($entityId);
  75. }
  76. $query
  77. ->orderBy('.dateReminder')
  78. ->groupBy('.id');
  79. return $query->find();
  80. }
  81. }