Files
Phraseanet/lib/Alchemy/Phrasea/Model/Repositories/UserSettingRepository.php
2014-01-06 15:40:56 +01:00

54 lines
1.3 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Model\Repositories;
use Doctrine\ORM\EntityRepository;
/**
* UserSettingRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UserSettingRepository extends EntityRepository
{
/**
* Returns a collection of FeedEntry from given feeds, limited to $how_many results, starting with $offset_start
*
* @param array $feeds
* @param integer $offsetStart
* @param integer $howMany
*
* @return \Doctrine\Common\Collections\Collection
*/
public function findByFeeds($feeds, $offsetStart = null, $perPage = null)
{
$qb = $this->createQueryBuilder('f');
if (!empty($feeds)) {
$qb->Where($qb->expr()->in('f.feed', $feeds));
}
$qb->orderBy('f.updatedOn', 'DESC');
if ($offsetStart) {
$qb->setFirstResult(max(0, (int) $offsetStart));
}
if ($perPage) {
$qb->setMaxResults(max(5, (int) $perPage));
}
return $qb->getQuery()->getResult();
}
}