mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-15 19:42:08 +00:00
Add filter for tags on API
This commit is contained in:
parent
a314b920bf
commit
28803f106b
3 changed files with 31 additions and 2 deletions
|
@ -95,9 +95,10 @@ class EntryRepository extends EntityRepository
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0)
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->leftJoin('e.tags', 't')
|
||||
->where('e.user =:userId')->setParameter('userId', $userId);
|
||||
|
||||
if (null !== $isArchived) {
|
||||
|
@ -110,6 +111,11 @@ class EntryRepository extends EntityRepository
|
|||
|
||||
if ($since >= 0) {
|
||||
$qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
|
||||
|
||||
if ('' !== $tags) {
|
||||
foreach (explode(',', $tags) as $tag) {
|
||||
$qb->andWhere('t.label = :label')->setParameter('label', $tag);
|
||||
}
|
||||
}
|
||||
|
||||
if ('created' === $sort) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue