X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FSiteCredentialRepository.php;h=316ecc75020e5400ef272a7e97664a50b6aa8910;hb=5a9bc00726ddaf7c8798d4932d0a8b7a38422670;hp=88aee6d583da41fa777e6987365c7e176937aea5;hpb=fc6d92c63dc5629a9e005628e416e0ecf4daa6ed;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index 88aee6d5..316ecc75 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php @@ -7,4 +7,22 @@ namespace Wallabag\CoreBundle\Repository; */ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository { + /** + * Retrieve one username/password for the given host and userId. + * + * @param string $host + * @param int $userId + * + * @return null|array + */ + public function findOneByHostAndUser($host, $userId) + { + return $this->createQueryBuilder('s') + ->select('s.username', 's.password') + ->where('s.host = :hostname')->setParameter('hostname', $host) + ->andWhere('s.user = :userId')->setParameter('userId', $userId) + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult(); + } }