|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
-
- namespace Lc\SovBundle\Repository\Reminder;
-
- class ReminderStore implements ReminderStoreInterface
- {
- protected ReminderRepositoryQueryInterface $query;
-
- public function __construct(ReminderRepositoryQueryInterface $query)
- {
- $this->query = $query;
- }
-
- public function get($params = [], $query = null)
- {
- if(is_null($query)) {
- $query = $this->query->create();
- }
-
- $query->filterDone();
-
- if(array_key_exists('user', $params)) {
- $query->filterUser($params['user']);
- }
-
- if(array_key_exists('crudAction', $params)) {
- $query->filterCrudAction($params['crudAction']);
- }
-
- if(array_key_exists('crudControllerFqcn', $params)) {
- $query->filterCrudControllerFqcn($params['crudControllerFqcn']);
- }
-
- if(array_key_exists('entityId', $params)) {
- $query->filterEntityId($params['entityId']);
- }
-
- $query->orderDefault();
-
- return $query->find();
- }
-
- /*
- public function findByUser($user)
- {
- $qb = $this->createQueryBuilder('e')
- ->leftJoin('e.users', 'u')
- ->having('COUNT(u.id) = 0')
- ->orHaving(':user MEMBER OF e.users')
- ->andWhere('e.done = 0')
- ->setParameter('user', $user)
- ->orderBy('e.dateReminder', 'ASC')
- ->groupBy('e.id');
-
- return $qb->getQuery()->getResult();
- }
-
- public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
- {
- $qb = $this->createQueryBuilder('e');
- $qb->leftJoin('e.users', 'u');
- $qb->having('COUNT(u.id) = 0');
- $qb->orHaving(':user MEMBER OF e.users');
- $qb->andWhere('e.done = 0');
- $qb->andWhere('e.crudAction LIKE :crudAction');
- $qb->andWhere('e.crudControllerFqcn LIKE :entity');
- $qb->setParameter('crudAction', $crudAction);
- $qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
- $qb->setParameter('user', $user);
- if ($entityId) {
- $qb->andWhere('e.entityId LIKE :id');
- $qb->setParameter('entityId', $entityId);
- }
- $qb->orderBy('e.dateReminder', 'ASC');
- $qb->groupBy('e.id');
-
- return $qb->getQuery()->getResult();
- }*/
- }
|