src/Repository/SectionTitleRepository.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\SectionTitle;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\ORM\OptimisticLockException;
  6. use Doctrine\ORM\ORMException;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. /**
  9.  * @extends ServiceEntityRepository<SectionTitle>
  10.  *
  11.  * @method SectionTitle|null find($id, $lockMode = null, $lockVersion = null)
  12.  * @method SectionTitle|null findOneBy(array $criteria, array $orderBy = null)
  13.  * @method SectionTitle[]    findAll()
  14.  * @method SectionTitle[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  15.  */
  16. class SectionTitleRepository extends ServiceEntityRepository {
  17.     public function __construct(ManagerRegistry $registry) {
  18.         parent::__construct($registry, SectionTitle::class);
  19.     }
  20.     /**
  21.      * @throws ORMException
  22.      * @throws OptimisticLockException
  23.      */
  24.     public function add(SectionTitle $entity, bool $flush = true): void {
  25.         $this->_em->persist($entity);
  26.         if ($flush) {
  27.             $this->_em->flush();
  28.         }
  29.     }
  30.     /**
  31.      * @throws ORMException
  32.      * @throws OptimisticLockException
  33.      */
  34.     public function remove(SectionTitle $entity, bool $flush = true): void {
  35.         $this->_em->remove($entity);
  36.         if ($flush) {
  37.             $this->_em->flush();
  38.         }
  39.     }
  40.     /**
  41.      * @return Home[] Returns an array of Home objects
  42.      */
  43.     public function findTitleByTag($tagName) {
  44.         return $this->createQueryBuilder('p')
  45.                         ->join('p.tag', 't')
  46.                         ->andWhere('t.name = :title')
  47.                         ->setParameter('title', $tagName)
  48.                         ->orderBy('p.title')
  49.                         ->getQuery()
  50.                         ->getResult();
  51.     }
  52.     /*
  53.       public function findOneBySomeField($value): ?SectionTitle
  54.       {
  55.       return $this->createQueryBuilder('s')
  56.       ->andWhere('s.exampleField = :val')
  57.       ->setParameter('val', $value)
  58.       ->getQuery()
  59.       ->getOneOrNullResult()
  60.       ;
  61.       }
  62.      */
  63. }