src/Repository/RadioRepository.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\Radio;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @method Radio|null find($id, $lockMode = null, $lockVersion = null)
  8.  * @method Radio|null findOneBy(array $criteria, array $orderBy = null)
  9.  * @method Radio[]    findAll()
  10.  * @method Radio[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11.  */
  12. class RadioRepository extends ServiceEntityRepository
  13. {
  14.     public function __construct(ManagerRegistry $registry)
  15.     {
  16.         parent::__construct($registryRadio::class);
  17.     }
  18.     /**
  19.      * @return Radio[] Returns an array of Radio objects
  20.      */
  21.     public function findUserRadios($user)
  22.     {
  23.         return $this->createQueryBuilder('r')
  24.             ->andWhere('r.owner = :owner')
  25.             ->setParameter('owner'$user)
  26.             ->orderBy('r.name''ASC')
  27.             ->getQuery()
  28.             ->getResult();
  29.     }
  30.     /**
  31.      * @return int Returns the number of shared radios
  32.      */
  33.     public function getSharedRadiosCount()
  34.     {
  35.         $qb $this->createQueryBuilder('r')
  36.             ->select('count(r.id)')
  37.             ->andWhere('r.published = 1')
  38.             ->andWhere('r.reviewed = 1');
  39.         return $qb
  40.             ->getQuery()
  41.             ->getSingleScalarResult();
  42.     }
  43.     public function getSharedRadioCountryCount()
  44.     {
  45.         $qb $this->createQueryBuilder('r')
  46.             ->select('count(distinct r.country)')
  47.             ->andWhere('r.published = 1')
  48.             ->andWhere('r.reviewed = 1');
  49.         return $qb
  50.             ->getQuery()
  51.             ->getSingleScalarResult();
  52.     }
  53.     // /**
  54.     //  * @return Radio[] Returns an array of Radio objects
  55.     //  */
  56.     /*
  57.     public function findByExampleField($value)
  58.     {
  59.         return $this->createQueryBuilder('r')
  60.             ->andWhere('r.exampleField = :val')
  61.             ->setParameter('val', $value)
  62.             ->orderBy('r.id', 'ASC')
  63.             ->setMaxResults(10)
  64.             ->getQuery()
  65.             ->getResult()
  66.         ;
  67.     }
  68.     */
  69.     /*
  70.     public function findOneBySomeField($value): ?Radio
  71.     {
  72.         return $this->createQueryBuilder('r')
  73.             ->andWhere('r.exampleField = :val')
  74.             ->setParameter('val', $value)
  75.             ->getQuery()
  76.             ->getOneOrNullResult()
  77.         ;
  78.     }
  79.     */
  80. }