diff --git a/apps/src/Repository/CategoryRepository.php b/apps/src/Repository/CategoryRepository.php index 55270a9e5..869a100bc 100644 --- a/apps/src/Repository/CategoryRepository.php +++ b/apps/src/Repository/CategoryRepository.php @@ -28,50 +28,28 @@ public function findAllParentForAdmin(array $get): QueryBuilder public function findByBookmark() { - $entityManager = $this->getEntityManager(); - $dql = $entityManager->createQueryBuilder(); - $dql->select('a'); - $dql->from(Category::class, 'a'); - $dql->leftJoin('a.bookmarks', 'b'); - $dql->innerjoin('b.refuser', 'u'); - $dql->where('b.state LIKE :state'); - $dql->setParameters( - ['state' => '%publie%'] - ); - - return $dql->getQuery()->getResult(); - } - - public function findByBookmark() - { - $entityManager = $this->getEntityManager(); - $dql = $entityManager->createQueryBuilder(); - $dql->select('a'); - $dql->from(Category::class, 'a'); - $dql->leftJoin('a.bookmarks', 'b'); - $dql->innerjoin('b.refuser', 'u'); - $dql->where('b.state LIKE :state'); - $dql->setParameters( + $queryBuilder = $this->createQueryBuilder('a'); + $query = $queryBuilder->leftJoin('a.bookmarks', 'b'); + $query->innerjoin('b.refuser', 'u'); + $query->where('b.state LIKE :state'); + $query->setParameters( ['state' => '%publie%'] ); - return $dql->getQuery()->getResult(); + return $query->getQuery()->getResult(); } public function findByPost() { - $entityManager = $this->getEntityManager(); - $dql = $entityManager->createQueryBuilder(); - $dql->select('a'); - $dql->from(Category::class, 'a'); - $dql->leftJoin('a.posts', 'p'); - $dql->innerjoin('p.refuser', 'u'); - $dql->where('p.state LIKE :state'); - $dql->setParameters( + $queryBuilder = $this->createQueryBuilder('a'); + $query = $queryBuilder->leftJoin('a.posts', 'p'); + $query->innerjoin('p.refuser', 'u'); + $query->where('p.state LIKE :state'); + $query->setParameters( ['state' => '%publie%'] ); - return $dql->getQuery()->getResult(); + return $query->getQuery()->getResult(); } public function findName(string $field) diff --git a/apps/src/Repository/LibelleRepository.php b/apps/src/Repository/LibelleRepository.php index 7ad4384e6..741fc7c5b 100644 --- a/apps/src/Repository/LibelleRepository.php +++ b/apps/src/Repository/LibelleRepository.php @@ -20,34 +20,29 @@ public function __construct(ManagerRegistry $registry) public function findByBookmark() { - $entityManager = $this->getEntityManager(); - $dql = $entityManager->createQueryBuilder(); - $dql->select('a'); - $dql->from(Libelle::class, 'a'); - $dql->innerJoin('a.bookmarks', 'b'); - $dql->innerjoin('b.refuser', 'u'); - $dql->where('b.state LIKE :state'); - $dql->setParameters( + $queryBuilder = $this->createQueryBuilder('a'); + $query = $queryBuilder->from(Libelle::class, 'a'); + $query->innerJoin('a.bookmarks', 'b'); + $query->innerjoin('b.refuser', 'u'); + $query->where('b.state LIKE :state'); + $query->setParameters( ['state' => '%publie%'] ); - return $dql->getQuery()->getResult(); + return $query->getQuery()->getResult(); } public function findByPost() { - $entityManager = $this->getEntityManager(); - $dql = $entityManager->createQueryBuilder(); - $dql->select('a'); - $dql->from(Libelle::class, 'a'); - $dql->innerJoin('a.posts', 'p'); - $dql->innerjoin('p.refuser', 'u'); - $dql->where('p.state LIKE :state'); - $dql->setParameters( + $queryBuilder = $this->createQueryBuilder('a'); + $query = $queryBuilder->innerJoin('a.posts', 'p'); + $query->innerjoin('p.refuser', 'u'); + $query->where('p.state LIKE :state'); + $query->setParameters( ['state' => '%publie%'] ); - return $dql->getQuery()->getResult(); + return $query->getQuery()->getResult(); } public function findNom(string $field) diff --git a/apps/src/Repository/MenuRepository.php b/apps/src/Repository/MenuRepository.php index af11b1f40..e865c9ce8 100644 --- a/apps/src/Repository/MenuRepository.php +++ b/apps/src/Repository/MenuRepository.php @@ -20,7 +20,6 @@ public function __construct(ManagerRegistry $registry) public function findAllCode() { $queryBuilder = $this->createQueryBuilder('u'); - $query = $queryBuilder->select('u'); $query = $queryBuilder->where( 'u.position=0' ); diff --git a/apps/src/Repository/PostRepository.php b/apps/src/Repository/PostRepository.php index 4640b4ba6..492c39888 100644 --- a/apps/src/Repository/PostRepository.php +++ b/apps/src/Repository/PostRepository.php @@ -21,8 +21,7 @@ public function __construct(ManagerRegistry $registry) public function findDateArchive() { $queryBuilder = $this->createQueryBuilder('p'); - $query = $queryBuilder->innerjoin('p.refuser', 'u'); - $query->select( + $query = $queryBuilder->select( 'date_format(p.published,\'%Y-%m\') as code, p.published, COUNT(p)' ); $query->where(