Make repositories use ServiceEntityRepository

This commit is contained in:
Yassine Guedidi 2022-08-27 23:01:09 +02:00
parent 51884911f5
commit 1bee0eeb29
11 changed files with 95 additions and 42 deletions

View file

@ -109,27 +109,23 @@ services:
Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor: ~
# repository as a service
Wallabag\CoreBundle\Repository\EntryRepository:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- 'Wallabag\CoreBundle\Entity\Entry'
Wallabag\AnnotationBundle\Repository\AnnotationRepository: ~
Wallabag\CoreBundle\Repository\TagRepository:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- 'Wallabag\CoreBundle\Entity\Tag'
Wallabag\ApiBundle\Repository\ClientRepository: ~
Wallabag\CoreBundle\Repository\SiteCredentialRepository:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- 'Wallabag\CoreBundle\Entity\SiteCredential'
calls:
- [ setCrypto, [ '@Wallabag\CoreBundle\Helper\CryptoProxy' ] ]
Wallabag\CoreBundle\Repository\ConfigRepository: ~
Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- 'Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule'
Wallabag\CoreBundle\Repository\EntryRepository: ~
Wallabag\CoreBundle\Repository\TagRepository: ~
Wallabag\CoreBundle\Repository\TaggingRuleRepository: ~
Wallabag\CoreBundle\Repository\SiteCredentialRepository: ~
Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository: ~
Wallabag\CoreBundle\Repository\IgnoreOriginUserRuleRepository: ~
Wallabag\CoreBundle\Helper\EntriesExport:
arguments:
@ -209,10 +205,7 @@ services:
Wallabag\UserBundle\EventListener\PasswordResettingListener: ~
Wallabag\UserBundle\Repository\UserRepository:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- 'Wallabag\UserBundle\Entity\User'
Wallabag\UserBundle\Repository\UserRepository: ~
Wallabag\UserBundle\EventListener\CreateConfigListener:
arguments:

View file

@ -2,15 +2,21 @@
namespace Wallabag\AnnotationBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\AnnotationBundle\Entity\Annotation;
/**
* AnnotationRepository.
*/
class AnnotationRepository extends EntityRepository
class AnnotationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Annotation::class);
}
/**
* Retrieves all annotations for a user.
*

View file

@ -2,10 +2,17 @@
namespace Wallabag\ApiBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\ApiBundle\Entity\Client;
class ClientRepository extends EntityRepository
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'])) {

View file

@ -2,8 +2,14 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\Config;
class ConfigRepository extends EntityRepository
class ConfigRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Config::class);
}
}

View file

@ -2,17 +2,23 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\UrlHasher;
class EntryRepository extends EntityRepository
class EntryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Entry::class);
}
/**
* Retrieves all entries for a user.
*

View file

@ -2,8 +2,14 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
class IgnoreOriginInstanceRuleRepository extends EntityRepository
class IgnoreOriginInstanceRuleRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IgnoreOriginInstanceRule::class);
}
}

View file

@ -2,8 +2,14 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
class IgnoreOriginUserRuleRepository extends EntityRepository
class IgnoreOriginUserRuleRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IgnoreOriginUserRule::class);
}
}

View file

@ -2,17 +2,22 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Helper\CryptoProxy;
/**
* SiteCredentialRepository.
*/
class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository
class SiteCredentialRepository extends ServiceEntityRepository
{
private $cryptoProxy;
public function setCrypto(CryptoProxy $cryptoProxy)
public function __construct(ManagerRegistry $registry, CryptoProxy $cryptoProxy)
{
parent::__construct($registry, SiteCredential::class);
$this->cryptoProxy = $cryptoProxy;
}

View file

@ -2,12 +2,18 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\Tag;
class TagRepository extends EntityRepository
class TagRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Tag::class);
}
/**
* Count all tags per user.
*

View file

@ -2,8 +2,14 @@
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\TaggingRule;
class TaggingRuleRepository extends EntityRepository
class TaggingRuleRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, TaggingRule::class);
}
}

View file

@ -2,12 +2,18 @@
namespace Wallabag\UserBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Wallabag\UserBundle\Entity\User;
class UserRepository extends EntityRepository
class UserRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
/**
* Find a user by its username and Feed token.
*