|
|
@@ -16,16 +16,14 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface |
|
|
|
|
|
|
|
public function get($params = [], $query = null) |
|
|
|
{ |
|
|
|
if (is_null($query)) { |
|
|
|
$query = $this->query->create(); |
|
|
|
} |
|
|
|
$query = $this->createQuery($query); |
|
|
|
|
|
|
|
$query->filterByDone(); |
|
|
|
|
|
|
|
if (array_key_exists('user', $params)) { |
|
|
|
$query |
|
|
|
->filterByUser($params['user']) |
|
|
|
->groupBy('.id'); |
|
|
|
->filterByUser($params['user']) |
|
|
|
->groupBy('.id'); |
|
|
|
} |
|
|
|
|
|
|
|
if (array_key_exists('crudAction', $params)) { |
|
|
@@ -48,104 +46,43 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface |
|
|
|
// findByUser |
|
|
|
public function getByUser(UserInterface $user, $query = null): array |
|
|
|
{ |
|
|
|
if (is_null($query)) { |
|
|
|
$query = $this->query->create(); |
|
|
|
} |
|
|
|
$query = $this->createQuery($query); |
|
|
|
|
|
|
|
$query = $this->query->create(); |
|
|
|
|
|
|
|
$query |
|
|
|
->filterByUser($user) |
|
|
|
->filterIsNotDone() |
|
|
|
->orderBy('.dateReminder') |
|
|
|
->groupBy('.id'); |
|
|
|
->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 |
|
|
|
string $crudAction, |
|
|
|
string $crudControllerFqcn, |
|
|
|
UserInterface $user, |
|
|
|
int $entityId = null, |
|
|
|
$query = null |
|
|
|
): array { |
|
|
|
if (is_null($query)) { |
|
|
|
$query = $this->query->create(); |
|
|
|
} |
|
|
|
$query = $this->createQuery($query); |
|
|
|
|
|
|
|
$query |
|
|
|
->filterByUser($user) |
|
|
|
->filterLikeCrudAction($crudAction) |
|
|
|
->filterLikeCrudControllerFqcn($crudControllerFqcn) |
|
|
|
->filterIsNotDone(); |
|
|
|
->filterByUser($user) |
|
|
|
->filterLikeCrudAction($crudAction) |
|
|
|
->filterLikeCrudControllerFqcn($crudControllerFqcn) |
|
|
|
->filterIsNotDone(); |
|
|
|
|
|
|
|
if ($entityId) { |
|
|
|
$query |
|
|
|
->filterLikeEntityId($entityId); |
|
|
|
->filterLikeEntityId($entityId); |
|
|
|
} |
|
|
|
$query |
|
|
|
->orderBy('.dateReminder') |
|
|
|
->groupBy('.id'); |
|
|
|
->orderBy('.dateReminder') |
|
|
|
->groupBy('.id'); |
|
|
|
|
|
|
|
return $query->find(); |
|
|
|
} |
|
|
|
|
|
|
|
// 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(); |
|
|
|
// } |
|
|
|
} |
|
|
|
/* |
|
|
|
|
|
|
|
public function getRemindersByUser($user) |
|
|
|
{ |
|
|
|
$reminderRepo = $this->em->getRepository(ReminderInterface::class); |
|
|
|
|
|
|
|
|
|
|
|
$reminders = $reminderRepo->findByUser($user); |
|
|
|
|
|
|
|
$entitiesRepo = array(); |
|
|
|
$entitiesConfig = array(); |
|
|
|
if (count($reminders) > 0) { |
|
|
|
foreach ($reminders as $reminder) { |
|
|
|
if ($reminder->getEntityName()) { |
|
|
|
if (!isset($entitiesConfig[$reminder->getEntityName()])) { |
|
|
|
$entitiesConfig[$reminder->getEntityName()] = $this->configManager->getEntityConfig($reminder->getEntityName()); |
|
|
|
} |
|
|
|
if ($reminder->getEntityAction() == 'edit' || $reminder->getEntityAction() == 'show') { |
|
|
|
if (!isset($entitiesRepo[$reminder->getEntityName()])) { |
|
|
|
$entitiesRepo[$reminder->getEntityName()] = $this->em->getRepository($entitiesConfig[$reminder->getEntityName()]['class']); |
|
|
|
} |
|
|
|
|
|
|
|
if ($reminder->getEntityId()) { |
|
|
|
$reminder->relatedPage = $entitiesRepo[$reminder->getEntityName()]->find($reminder->getEntityId())->__toString(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
$reminder->relatedPage = 'Liste de ' . $entitiesConfig[$reminder->getEntityName()]['label']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $reminders; |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
} |