Add LazaretCheck, update LazaretFile

This commit is contained in:
Romain Neutron
2012-05-15 16:43:46 +02:00
parent fc0a7b87d9
commit e1c15e67ba
10 changed files with 760 additions and 39 deletions

View File

@@ -1,48 +1,34 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Repositories;
use Doctrine\ORM\EntityRepository;
use Entities;
/**
* LazaretFileRepository
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class LazaretFileRepository extends EntityRepository
{
/**
* Returns all lazaret files for a given offset & limit
*
* @param int $offset
* @param int $limit
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getFiles($offset, $limit)
public function findPerPage(array $base_ids, $offset = 0, $perPage = 10)
{
$qb = $this->_em->createQueryBuilder();
$base_ids = implode(', ', array_map(function($int) {
return (int) $int;
}, $base_ids));
$qb
->add('select', 'l')
->add('from', 'Entities\LazaretFile l')
->add('orderBy', 'l.updated DESC')
->setFirstResult($offset)
->setMaxResults($limit);
$dql = 'SELECT f
FROM Entities\LazaretFile f
WHERE f.base_id IN (' . $base_ids . ') ORDER BY id DESC';
$query = $qb->getQuery();
$query = $this->_em->createQuery($dql);
$query->setFirstResult($offset)
->setMaxResults($perPage);
return $query->getResult();
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
return $paginator;
}
}