Allow snips to be archived
This commit is contained in:
@ -50,6 +50,7 @@ class SnipRepository extends ServiceEntityRepository
|
||||
->setParameter('user', $user)
|
||||
;
|
||||
|
||||
$showArchived = false;
|
||||
switch ($request->visibility) {
|
||||
case SnipFilterRequest::VISIBILITY_ALL:
|
||||
break;
|
||||
@ -59,9 +60,13 @@ class SnipRepository extends ServiceEntityRepository
|
||||
case SnipFilterRequest::VISIBILITY_HIDDEN:
|
||||
$qb->andWhere('s.visible = false');
|
||||
break;
|
||||
case SnipFilterRequest::VISIBILITY_ARCHIVED:
|
||||
$showArchived = true;
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid visibility option: ', $request->visibility);
|
||||
}
|
||||
$qb->andWhere('s.archived = ' . ($showArchived ? 'true' : 'false'));
|
||||
|
||||
switch ($request->sort) {
|
||||
case SnipFilterRequest::SORT_NAME:
|
||||
@ -73,6 +78,7 @@ class SnipRepository extends ServiceEntityRepository
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid sort option: ', $request->sort);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
@ -82,6 +88,7 @@ class SnipRepository extends ServiceEntityRepository
|
||||
->createQueryBuilder('s')
|
||||
->where('s.public = true')
|
||||
->andWhere('s.visible = true')
|
||||
->andWhere('s.archived = false')
|
||||
->orderBy('s.createdAt', 'DESC')
|
||||
;
|
||||
|
||||
|
Reference in New Issue
Block a user