]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php
Retrieve username/password from database
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / SiteCredentialRepository.php
CommitLineData
f92fcb53
JB
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5/**
6 * SiteCredentialRepository.
f92fcb53
JB
7 */
8class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository
9{
5a9bc007
JB
10 /**
11 * Retrieve one username/password for the given host and userId.
12 *
13 * @param string $host
14 * @param int $userId
15 *
16 * @return null|array
17 */
18 public function findOneByHostAndUser($host, $userId)
19 {
20 return $this->createQueryBuilder('s')
21 ->select('s.username', 's.password')
22 ->where('s.host = :hostname')->setParameter('hostname', $host)
23 ->andWhere('s.user = :userId')->setParameter('userId', $userId)
24 ->setMaxResults(1)
25 ->getQuery()
26 ->getOneOrNullResult();
27 }
f92fcb53 28}