src/Repository/ForumReponseRepository.php line 70

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\ForumReponse;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @extends ServiceEntityRepository<ForumReponse>
  8.  *
  9.  * @method ForumReponse|null find($id, $lockMode = null, $lockVersion = null)
  10.  * @method ForumReponse|null findOneBy(array $criteria, array $orderBy = null)
  11.  * @method ForumReponse[]    findAll()
  12.  * @method ForumReponse[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  13.  */
  14. class ForumReponseRepository extends ServiceEntityRepository
  15. {
  16.     public function __construct(ManagerRegistry $registry)
  17.     {
  18.         parent::__construct($registryForumReponse::class);
  19.     }
  20.     public function add(ForumReponse $entitybool $flush false): void
  21.     {
  22.         $this->getEntityManager()->persist($entity);
  23.         if ($flush) {
  24.             $this->getEntityManager()->flush();
  25.         }
  26.     }
  27.     public function remove(ForumReponse $entitybool $flush false): void
  28.     {
  29.         $this->getEntityManager()->remove($entity);
  30.         if ($flush) {
  31.             $this->getEntityManager()->flush();
  32.         }
  33.     }
  34. //    /**
  35. //     * @return ForumReponse[] Returns an array of ForumReponse objects
  36. //     */
  37. //    public function findByExampleField($value): array
  38. //    {
  39. //        return $this->createQueryBuilder('f')
  40. //            ->andWhere('f.exampleField = :val')
  41. //            ->setParameter('val', $value)
  42. //            ->orderBy('f.id', 'ASC')
  43. //            ->setMaxResults(10)
  44. //            ->getQuery()
  45. //            ->getResult()
  46. //        ;
  47. //    }
  48. //    public function findOneBySomeField($value): ?ForumReponse
  49. //    {
  50. //        return $this->createQueryBuilder('f')
  51. //            ->andWhere('f.exampleField = :val')
  52. //            ->setParameter('val', $value)
  53. //            ->getQuery()
  54. //            ->getOneOrNullResult()
  55. //        ;
  56. //    }
  57.     /**
  58.      * @return ForumReponse[] Returns an array of ForumReponse objects
  59.     */
  60.     public function finResponsesdWithUser($sujetForum$user null$ofsset ): array
  61.     {
  62.         return $this->createQueryBuilder('f')
  63.             ->where('f.etat = :val1')
  64.             ->andWhere('f.sujetforum = :val2')
  65.             ->andWhere('f.parent is NULL')
  66.             ->orWhere('f.user = :val3')
  67.             ->andWhere('f.sujetforum = :val2')
  68.             ->andWhere('f.parent is NULL')
  69.             ->setParameter('val1'true)
  70.             ->setParameter('val2'$sujetForum)
  71.             ->setParameter('val3'$user)
  72.             ->orderBy('f.id''DESC')
  73.             ->setFirstResult($ofsset)
  74.             ->setMaxResults(1// Set maximum results to 3
  75.             ->getQuery()
  76.             ->getResult()
  77.         ;
  78.     }
  79.     public function findTopLevelResponses()
  80.     {
  81.         return $this->createQueryBuilder('r')
  82.             ->where('r.parent IS NULL')
  83.             ->getQuery()
  84.             ->getResult();
  85.     }
  86. }