aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/UserBundle/Repository/UserRepository.php
blob: c020f3ca9478a6418ec1e4bc6732610a5999fe7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace Wallabag\UserBundle\Repository;

use Doctrine\ORM\EntityRepository;

class UserRepository extends EntityRepository
{
    /**
     * Find a user by its username and rss roken.
     *
     * @param string $username
     * @param string $rssToken
     *
     * @return User|null
     */
    public function findOneByUsernameAndRsstoken($username, $rssToken)
    {
        return $this->createQueryBuilder('u')
            ->leftJoin('u.config', 'c')
            ->where('c.rssToken = :rss_token')->setParameter('rss_token', $rssToken)
            ->andWhere('u.username = :username')->setParameter('username', $username)
            ->getQuery()
            ->getOneOrNullResult();
    }
}