Move Api repository to Core

This commit is contained in:
Yassine Guedidi
2023-12-31 09:36:05 +01:00
parent 81577ef6b0
commit 1bddf4ee19
3 changed files with 3 additions and 3 deletions

View File

@ -9,9 +9,9 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Wallabag\ApiBundle\Form\Type\ClientType;
use Wallabag\ApiBundle\Repository\ClientRepository;
use Wallabag\CoreBundle\Controller\AbstractController;
use Wallabag\CoreBundle\Entity\Api\Client;
use Wallabag\CoreBundle\Repository\Api\ClientRepository;
class DeveloperController extends AbstractController
{

View File

@ -12,7 +12,7 @@ use Wallabag\CoreBundle\Entity\User;
/**
* @ORM\Table("oauth2_clients")
* @ORM\Entity(repositoryClass="Wallabag\ApiBundle\Repository\ClientRepository")
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\Api\ClientRepository")
*/
class Client extends BaseClient
{

View File

@ -0,0 +1,29 @@
<?php
namespace Wallabag\CoreBundle\Repository\Api;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\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);
}
}