<?php
namespace App\Repository;
use App\Entity\Repertoire;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use App\Utils\Constants;
/**
* @extends ServiceEntityRepository<Repertoire>
*
* @method Repertoire|null find($id, $lockMode = null, $lockVersion = null)
* @method Repertoire|null findOneBy(array $criteria, array $orderBy = null)
* @method Repertoire[] findAll()
* @method Repertoire[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class RepertoireRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Repertoire::class);
}
public function save(Repertoire $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(Repertoire $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function getByReportType($type = null, $org) {
if(is_null($type)) {
return null;
}
return $this->createQueryBuilder('c')
->orWhere('c.status = :status AND c.organisation = :orgId AND c.report_type = :type')
->addOrderBy('c.name', 'ASC')
->setParameter('status', Constants::ACTIVE)
->setParameter('type', $type)
->setParameter('orgId', $org)
->getQuery()
->getResult();
}
public function getByReportTypeName($type = null, $name, $org) {
if(is_null($type)) {
return null;
}
if(is_null($name)) {
return null;
}
return $this->createQueryBuilder('c')
->orWhere('c.status = :status AND c.organisation = :orgId AND c.report_type = :type AND c.name= :name')
->addOrderBy('c.name', 'ASC')
->setParameter('status', Constants::ACTIVE)
->setParameter('type', $type)
->setParameter('name', $name)
->setParameter('orgId', $org)
->getQuery()
->getResult();
}
public function getByReportTypeNameInactive($type = null, $name, $org) {
if(is_null($type)) {
return null;
}
if(is_null($name)) {
return null;
}
return $this->createQueryBuilder('c')
->orWhere('c.status = :status AND c.organisation = :orgId AND c.report_type = :type AND c.name= :name')
->addOrderBy('c.name', 'ASC')
->setParameter('status', Constants::INACTIVE)
->setParameter('type', $type)
->setParameter('name', $name)
->setParameter('orgId', $org)
->getQuery()
->getResult();
}
// /**
// * @return Repertoire[] Returns an array of Repertoire objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Repertoire
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}