mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
docgen: improve listing for templates
This commit is contained in:
@@ -25,6 +25,18 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(DocGeneratorTemplate::class);
|
||||
}
|
||||
|
||||
public function countByEntity(string $entity): int
|
||||
{
|
||||
$builder = $this->repository->createQueryBuilder('t');
|
||||
|
||||
$builder
|
||||
->select('count(t)')
|
||||
->where('t.entities LIKE :entity')
|
||||
->setParameter('entity', '%' . addslashes($entity) . '%');
|
||||
|
||||
return $builder->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
@@ -49,7 +61,10 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findByEntity($entity)
|
||||
/**
|
||||
* @return array|DocGeneratorTemplate[]
|
||||
*/
|
||||
public function findByEntity(string $entity, ?int $start = 0, ?int $limit = 50): array
|
||||
{
|
||||
$builder = $this->repository->createQueryBuilder('t');
|
||||
|
||||
@@ -57,7 +72,11 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
|
||||
->where('t.entities LIKE :entity')
|
||||
->setParameter('entity', '%' . addslashes($entity) . '%');
|
||||
|
||||
return $builder->getQuery()->execute();
|
||||
return $builder
|
||||
->getQuery()
|
||||
->setFirstResult($start)
|
||||
->setMaxResults($limit)
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?DocGeneratorTemplate
|
||||
|
Reference in New Issue
Block a user