<?php
declare(strict_types = 1);
namespace App\Domain\Repository;
use App\Domain\Entity\Text;
use App\Domain\Repository\Interfaces\TextRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class TextRepository extends ServiceEntityRepository implements TextRepositoryInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Text::class);
}
public function getContentByPageAndSection(string $page, string $section)
{
return $this->createQueryBuilder('text')
->innerJoin('text.page', 'p')
->innerJoin('text.section', 's')
->where('p.name = :page')
->andWhere('s.name = :section')
->setParameter('page', $page)
->setParameter('section', $section)
->setCacheable(true)
->getQuery()
->getOneOrNullResult();
}
public function getContentsByPageAndSection(string $page, string $section)
{
return $this->createQueryBuilder('text')
->innerJoin('text.page', 'p')
->innerJoin('text.section', 's')
->orderBy('text.createdAt', 'ASC')
->where('p.name = :page')
->andWhere('s.name = :section')
->setParameter('page', $page)
->setParameter('section', $section)
->setCacheable(true)
->getQuery()
->getResult();
}
}