Files
Phraseanet/lib/Alchemy/Phrasea/Model/Repositories/ApiAccountRepository.php
Benoît Burnichon fa283b74b5 Refactor DeveloperController
PHRAS-529 #time 1h
2015-06-18 14:49:53 +02:00

48 lines
1.3 KiB
PHP

<?php
namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
/**
* ApiAccountRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ApiAccountRepository extends EntityRepository
{
/**
* @param User $user
* @param ApiApplication $application
* @return ApiAccount
* @throws \Doctrine\ORM\NonUniqueResultException
*/
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();
}
/**
* @param User $user
* @return ApiAccount[]
*/
public function findByUser(User $user)
{
$qb = $this->createQueryBuilder('acc');
$qb->where($qb->expr()->eq('acc.user', ':user'));
$qb->setParameter(':user', $user);
return $qb->getQuery()->getResult();
}
}