forked from wallabag/wallabag
Add some fixtures
Improve test, so user can login Fix some leftJoin Cleanup EntryController
This commit is contained in:
@ -11,19 +11,20 @@ class EntryRepository extends EntityRepository
|
||||
/**
|
||||
* Retrieves unread entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $userId
|
||||
* @param int $firstResult
|
||||
* @param int $maxResults
|
||||
*
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('e.isArchived = false')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('u.id =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('e.isDeleted=false')
|
||||
->orderBy('e.createdAt', 'desc')
|
||||
->getQuery();
|
||||
@ -36,9 +37,10 @@ class EntryRepository extends EntityRepository
|
||||
/**
|
||||
* Retrieves read entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $userId
|
||||
* @param int $firstResult
|
||||
* @param int $maxResults
|
||||
*
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
|
||||
@ -47,8 +49,9 @@ class EntryRepository extends EntityRepository
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('e.isArchived = true')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('u.id =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('e.isDeleted=false')
|
||||
->orderBy('e.createdAt', 'desc')
|
||||
->getQuery();
|
||||
@ -61,9 +64,10 @@ class EntryRepository extends EntityRepository
|
||||
/**
|
||||
* Retrieves starred entries for a user
|
||||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $userId
|
||||
* @param int $firstResult
|
||||
* @param int $maxResults
|
||||
*
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findStarredByUser($userId, $firstResult, $maxResults = 12)
|
||||
@ -72,9 +76,10 @@ class EntryRepository extends EntityRepository
|
||||
->select('e')
|
||||
->setFirstResult($firstResult)
|
||||
->setMaxResults($maxResults)
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('e.isStarred = true')
|
||||
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('e.isDeleted=false')
|
||||
->andWhere('u.id =:userId')->setParameter('userId', $userId)
|
||||
->andWhere('e.isDeleted = false')
|
||||
->orderBy('e.createdAt', 'desc')
|
||||
->getQuery();
|
||||
|
||||
@ -83,22 +88,34 @@ class EntryRepository extends EntityRepository
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
public function findEntries($userId, $isArchived, $isStarred, $isDeleted, $sort, $order)
|
||||
/**
|
||||
* Find Entries
|
||||
*
|
||||
* @param int $userId
|
||||
* @param bool $isArchived
|
||||
* @param bool $isStarred
|
||||
* @param bool $isDeleted
|
||||
* @param string $sort
|
||||
* @param string $order
|
||||
*
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isDeleted = null, $sort = 'created', $order = 'ASC')
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e')
|
||||
->where('e.userId =:userId')->setParameter('userId', $userId);
|
||||
->leftJoin('e.user', 'u')
|
||||
->where('u.id =:userId')->setParameter('userId', $userId);
|
||||
|
||||
if (!is_null($isArchived)) {
|
||||
$qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', $isArchived);
|
||||
if (null !== $isArchived) {
|
||||
$qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived);
|
||||
}
|
||||
|
||||
if (!is_null($isStarred)) {
|
||||
$qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', $isStarred);
|
||||
if (null !== $isStarred) {
|
||||
$qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred);
|
||||
}
|
||||
|
||||
if (!is_null($isDeleted)) {
|
||||
$qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted);
|
||||
if (null !== $isDeleted) {
|
||||
$qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', (bool) $isDeleted);
|
||||
}
|
||||
|
||||
if ('created' === $sort) {
|
||||
|
||||
Reference in New Issue
Block a user