Open
Description
Description
I have this code
#[UniqueEntity(
fields: ['alias'],
entityClass: ParameterValue::class,
repositoryMethod: 'findMethod',
identifierFieldNames: ['id' => 'id'],
)]
and the repository method could be
public function findMethodi(array $criteria): bool
{
$entity = $this->createQueryBuilder('o')
->select('count(o.id)');
->andWhere('o.alias = :alias')
->setParameter('alias', $criteria['alias'])
->getQuery()
->getOneOrNullResult()
;
/** @var int $count */
$count = $qb->getQuery()->getSingleScalarResult();
return $count > 0;
}
The idea is that I don't need to download the complete data and certainly not hydrate it.
Sometimes just a method like this with COUNT(...) and returning a boolean is enough.
What do you think? Is it OK or would you rather write a new class and your own validator? Or integrate this?
If someone approves, I'll feel free to make a pull request. But if not, I don't want to waste time.
Thank you.
Example
No response