|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
-
- namespace Lc\SovBundle\Repository\Reminder;
-
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class ReminderStore extends AbstractStore implements ReminderStoreInterface
- {
- protected ReminderRepositoryQueryInterface $query;
-
- public function __construct(ReminderRepositoryQueryInterface $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function get($params = [], $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query->filterByDone();
-
- if (array_key_exists('user', $params)) {
- $query
- ->filterByUser($params['user'])
- ->groupBy('.id');
- }
-
- if (array_key_exists('crudAction', $params)) {
- $query->filterByCrudAction($params['crudAction']);
- }
-
- if (array_key_exists('crudControllerFqcn', $params)) {
- $query->filterByCrudControllerFqcn($params['crudControllerFqcn']);
- }
-
- if (array_key_exists('entityId', $params)) {
- $query->filterByEntityId($params['entityId']);
- }
-
- $query->orderBy('.dateReminder');
-
- return $query->find();
- }
-
- // findByUser
- public function getByUser(UserInterface $user, $query = null): array
- {
- $query = $this->createDefaultQuery($query);
-
- $query = $this->query->create();
-
- $query
- ->filterByUser($user)
- ->filterIsNotDone()
- ->orderBy('.dateReminder')
- ->groupBy('.id');
-
- return $query->find();
- }
-
- // findByEasyAdminConfigAndUser
- public function getByEasyAdminConfigAndUser(
- string $crudAction,
- string $crudControllerFqcn,
- UserInterface $user,
- int $entityId = null,
- $query = null
- ): array {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByUser($user)
- ->filterLikeCrudAction($crudAction)
- ->filterLikeCrudControllerFqcn($crudControllerFqcn)
- ->filterIsNotDone();
-
- if ($entityId) {
- $query
- ->filterLikeEntityId($entityId);
- }
- $query
- ->orderBy('.dateReminder')
- ->groupBy('.id');
-
- return $query->find();
- }
- }
|