Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

78 rindas
2.1KB

  1. <?php
  2. namespace Lc\SovBundle\Repository\Reminder;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  5. class ReminderRepositoryQuery extends AbstractRepositoryQuery implements ReminderRepositoryQueryInterface
  6. {
  7. public function __construct(ReminderRepository $repository, PaginatorInterface $paginator)
  8. {
  9. parent::__construct($repository, 'r', $paginator);
  10. }
  11. public function filterDone($done = false)
  12. {
  13. return $this
  14. ->andWhere('.done = :done')
  15. ->setParameter(':done', $done);
  16. }
  17. public function filterUser($user)
  18. {
  19. return $this
  20. ->leftJoin('.users', 'u')
  21. ->having('COUNT(u.id) = 0')
  22. ->orHaving(':user MEMBER OF .users')
  23. ->setParameter(':user', $user)
  24. ->groupBy('.id');
  25. }
  26. public function filterCrudAction($crudAction)
  27. {
  28. if(is_null($crudAction)) {
  29. return $this
  30. ->andWhere('.crudControllerFqcn IS NULL');
  31. }
  32. else {
  33. return $this
  34. ->andWhere('.crudAction = :crudAction')
  35. ->setParameter(':crudAction', $crudAction);
  36. }
  37. }
  38. public function filterCrudControllerFqcn($crudControllerFqcn)
  39. {
  40. if(is_null($crudControllerFqcn)) {
  41. return $this
  42. ->andWhere('.crudControllerFqcn IS NULL');
  43. }
  44. else {
  45. return $this
  46. ->andWhere('.crudControllerFqcn = :crudControllerFqcn')
  47. ->setParameter(':crudControllerFqcn', $crudControllerFqcn);
  48. }
  49. }
  50. public function filterEntityId($entityId)
  51. {
  52. if(is_null($entityId)) {
  53. return $this
  54. ->andWhere('.entityId IS NULL');
  55. }
  56. else {
  57. return $this
  58. ->andWhere('.entityId = :entityId')
  59. ->setParameter(':entityId', $entityId);
  60. }
  61. }
  62. public function orderDefault()
  63. {
  64. return $this
  65. ->orderBy('.dateReminder', 'ASC');
  66. }
  67. }