forked from wallabag/wallabag
move WallabagBundle into Wallabag:CoreBundle
This commit is contained in:
79
src/Wallabag/CoreBundle/Repository/EntriesRepository.php
Normal file
79
src/Wallabag/CoreBundle/Repository/EntriesRepository.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Repository;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
class EntriesRepository extends EntityRepository
|
||||
{
|
||||
/**
|
||||
* Retrieves unread entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->where('e.isRead = 0')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->getQuery();
|
||||
|
||||
$paginator = new Paginator($qb);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves read entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->where('e.isRead = 1')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->getQuery();
|
||||
|
||||
$paginator = new Paginator($qb);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves starred entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findStarredByUser($userId, $firstResult, $maxResults = 12)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->where('e.isFav = 1')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->getQuery();
|
||||
|
||||
$paginator = new Paginator($qb);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user