src/Domain/Repository/TextRepository.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Domain\Repository;
  4. use App\Domain\Entity\Text;
  5. use App\Domain\Repository\Interfaces\TextRepositoryInterface;
  6. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. class TextRepository extends ServiceEntityRepository implements TextRepositoryInterface
  9. {
  10.     public function __construct(ManagerRegistry $registry)
  11.     {
  12.         parent::__construct($registryText::class);
  13.     }
  14.     public function getContentByPageAndSection(string $pagestring $section)
  15.     {
  16.         return $this->createQueryBuilder('text')
  17.             ->innerJoin('text.page''p')
  18.             ->innerJoin('text.section''s')
  19.             ->where('p.name = :page')
  20.             ->andWhere('s.name = :section')
  21.             ->setParameter('page'$page)
  22.             ->setParameter('section'$section)
  23.             ->setCacheable(true)
  24.             ->getQuery()
  25.             ->getOneOrNullResult();
  26.     }
  27.     public function getContentsByPageAndSection(string $pagestring $section)
  28.     {
  29.         return $this->createQueryBuilder('text')
  30.             ->innerJoin('text.page''p')
  31.             ->innerJoin('text.section''s')
  32.             ->orderBy('text.createdAt''ASC')
  33.             ->where('p.name = :page')
  34.             ->andWhere('s.name = :section')
  35.             ->setParameter('page'$page)
  36.             ->setParameter('section'$section)
  37.             ->setCacheable(true)
  38.             ->getQuery()
  39.             ->getResult();
  40.     }
  41. }