mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 19:13:26 +00:00
37 lines
964 B
PHP
37 lines
964 B
PHP
<?php
|
|
|
|
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 Alchemy\Phrasea\Model\Entities\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;
|
|
}
|
|
}
|