mirror of
https://github.com/wallabag/wallabag.git
synced 2024-05-02 17:38:43 +00:00
30 lines
801 B
PHP
30 lines
801 B
PHP
<?php
|
|
|
|
namespace Wallabag\ApiBundle\Repository;
|
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
use Wallabag\ApiBundle\Entity\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);
|
|
}
|
|
}
|