<?php

namespace App\User\Framework\Repository;

use App\User\Framework\Entity\Preference;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<Preference>
 */
class PreferencesRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Preference::class);
    }

    /** @return Preference[] Returns an array of Preferences objects */
    public function findEnabled(): array
    {
        return $this->createQueryBuilder('p')
            ->andWhere('p.enabled = :val')
            ->setParameter('val', true)
            ->getQuery()
            ->getResult();
    }
}
