Files
Phraseanet/lib/Alchemy/Phrasea/Model/Repositories/LazaretFileRepository.php
2014-02-18 19:32:08 +01:00

46 lines
1.1 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;
/**
* LazaretFileRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class LazaretFileRepository extends EntityRepository
{
public function findPerPage(array $base_ids, $offset = 0, $perPage = 10)
{
$base_ids = implode(', ', array_map(function ($int) {
return (int) $int;
}, $base_ids));
$dql = '
SELECT f
FROM Phraseanet:LazaretFile f'
. ('' === $base_ids ? '' : ' WHERE f.base_id IN (' . $base_ids . ')')
. ' ORDER BY f.id DESC';
$query = $this->_em->createQuery($dql);
$query->setFirstResult($offset)
->setMaxResults($perPage);
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
return $paginator;
}
}