forked from wallabag/wallabag
Move Api repository to Core
This commit is contained in:
@ -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
|
||||
{
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
29
src/Wallabag/CoreBundle/Repository/Api/ClientRepository.php
Normal file
29
src/Wallabag/CoreBundle/Repository/Api/ClientRepository.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user