mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Add LazaretCheck, update LazaretFile
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user