Add findByUserAndApplication method

This commit is contained in:
Nicolas Le Goff
2014-03-05 17:17:37 +01:00
parent f792b0051f
commit b75d331a05

View File

@@ -2,6 +2,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Doctrine\ORM\EntityRepository;
/**
@@ -12,4 +13,14 @@ use Doctrine\ORM\EntityRepository;
*/
class ApiAccountRepository extends EntityRepository
{
public function findByUserAndApplication(User $user, ApiApplication $application)
{
$qb = $this->createQueryBuilder('acc');
$qb->where($qb->expr()->eq('acc.user', ':user'));
$qb->andWhere($qb->expr()->eq('acc.application', ':app'));
$qb->setParameter(':user', $user);
$qb->setParameter(':app', $application);
return $qb->getQuery()->getOneOrNullResult();
}
}