1
0
Fork 0
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:
Thomas Citharel 2016-06-25 16:27:38 +02:00
parent a314b920bf
commit 28803f106b
3 changed files with 31 additions and 2 deletions

View file

@ -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) {