aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index f5089729..3990932e 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -139,15 +139,30 @@ class EntryRepository extends EntityRepository
139 * @param string $order 139 * @param string $order
140 * @param int $since 140 * @param int $since
141 * @param string $tags 141 * @param string $tags
142 * @param string $detail 'metadata' or 'full'. Include content field if 'full'
143 *
144 * @todo Breaking change: replace default detail=full by detail=metadata in a future version
142 * 145 *
143 * @return Pagerfanta 146 * @return Pagerfanta
144 */ 147 */
145 public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '') 148 public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '', $detail = 'full')
146 { 149 {
150 if (!\in_array(strtolower($detail), ['full', 'metadata'], true)) {
151 throw new \Exception('Detail "' . $detail . '" parameter is wrong, allowed: full or metadata');
152 }
153
147 $qb = $this->createQueryBuilder('e') 154 $qb = $this->createQueryBuilder('e')
148 ->leftJoin('e.tags', 't') 155 ->leftJoin('e.tags', 't')
149 ->where('e.user = :userId')->setParameter('userId', $userId); 156 ->where('e.user = :userId')->setParameter('userId', $userId);
150 157
158 if ('metadata' === $detail) {
159 $fieldNames = $this->getClassMetadata()->getFieldNames();
160 $fields = array_filter($fieldNames, function ($k) {
161 return 'content' !== $k;
162 });
163 $qb->select(sprintf('partial e.{%s}', implode(',', $fields)));
164 }
165
151 if (null !== $isArchived) { 166 if (null !== $isArchived) {
152 $qb->andWhere('e.isArchived = :isArchived')->setParameter('isArchived', (bool) $isArchived); 167 $qb->andWhere('e.isArchived = :isArchived')->setParameter('isArchived', (bool) $isArchived);
153 } 168 }