瀏覽代碼

Correctifs

develop
Guillaume 3 年之前
父節點
當前提交
f6d050fb4e
共有 4 個檔案被更改,包括 64 行新增63 行删除
  1. +7
    -47
      Repository/Reminder/ReminderRepository.php
  2. +0
    -15
      Repository/Reminder/ReminderRepository2.php
  3. +56
    -0
      Repository/Reminder/ReminderRepositoryBack.php
  4. +1
    -1
      Repository/Reminder/ReminderRepositoryQuery.php

+ 7
- 47
Repository/Reminder/ReminderRepository.php 查看文件

@@ -2,55 +2,15 @@

namespace Lc\SovBundle\Repository\Reminder;

use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\Reminder\ReminderInterface;
use App\Entity\Reminder\Reminder;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ReminderInterface[] findAll()
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ReminderRepository extends AbstractRepository
class ReminderRepository extends ServiceEntityRepository implements ServiceEntityRepositoryInterface
{
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{
return ReminderInterface::class;
}

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();
parent::__construct($registry, Reminder::class);
}
}

+ 0
- 15
Repository/Reminder/ReminderRepository2.php 查看文件

@@ -1,15 +0,0 @@
<?php

namespace Lc\SovBundle\Repository\Reminder;

use App\Entity\Reminder\Reminder;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class ReminderRepository2 extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Reminder::class);
}
}

+ 56
- 0
Repository/Reminder/ReminderRepositoryBack.php 查看文件

@@ -0,0 +1,56 @@
<?php

namespace Lc\SovBundle\Repository\Reminder;

use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\Reminder\ReminderInterface;

/**
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ReminderInterface[] findAll()
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ReminderRepositoryBack extends AbstractRepository
{
public function getInterfaceClass()
{
return ReminderInterface::class;
}

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();
}
}

+ 1
- 1
Repository/Reminder/ReminderRepositoryQuery.php 查看文件

@@ -7,7 +7,7 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ReminderRepositoryQuery extends AbstractRepositoryQuery
{
public function __construct(ReminderRepository2 $repository, PaginatorInterface $paginator)
public function __construct(ReminderRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

Loading…
取消
儲存