]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Repository; | |
4 | ||
5 | /** | |
6 | * SiteCredentialRepository. | |
7 | */ | |
8 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | |
9 | { | |
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 | } | |
28 | } |