wallabag/src/Repository/Api/ClientRepository.php
2024-02-23 07:42:48 +01:00

30 lines
790 B
PHP

<?php
namespace Wallabag\Repository\Api;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\Entity\Api\Client;
/**
* @method Client[] findByUser(int $userId)
*/
class ClientRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Client::class);
}
public function findOneBy(array $criteria, ?array $orderBy = null)
{
if (!empty($criteria['id'])) {
// cast client id to be an integer to avoid postgres error:
// "invalid input syntax for integer"
$criteria['id'] = (int) $criteria['id'];
}
return parent::findOneBy($criteria, $orderBy);
}
}