namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
-use Doctrine\ORM\Query;
+use Doctrine\ORM\QueryBuilder;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
+use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
class EntryRepository extends EntityRepository
*
* @param int $userId
* @param string $term
- * @param strint $currentRoute
+ * @param string $currentRoute
*
* @return QueryBuilder
*/
* @param int $since
* @param string $tags
*
- * @return array
+ * @return Pagerfanta
*/
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
{
*
* @param int $userId
*
- * @return Entry
+ * @return array
*/
public function findOneWithTags($userId)
{
return (int) $qb->getQuery()->getSingleScalarResult();
}
- /**
- * Count all entries for a tag and a user.
- *
- * @param int $userId
- * @param int $tagId
- *
- * @return int
- */
- public function countAllEntriesByUserIdAndTagId($userId, $tagId)
- {
- $qb = $this->createQueryBuilder('e')
- ->select('count(e.id)')
- ->leftJoin('e.tags', 't')
- ->where('e.user=:userId')->setParameter('userId', $userId)
- ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
- ;
-
- return (int) $qb->getQuery()->getSingleScalarResult();
- }
-
/**
* Remove all entries for a user id.
* Used when a user want to reset all informations.
* Get id and url from all entries
* Used for the clean-duplicates command.
*/
- public function getAllEntriesIdAndUrl($userId)
+ public function findAllEntriesIdAndUrlByUserId($userId)
{
$qb = $this->createQueryBuilder('e')
->select('e.id, e.url')
return $qb->getQuery()->getArrayResult();
}
+ /**
+ * @param int $userId
+ *
+ * @return array
+ */
+ public function findAllEntriesIdByUserId($userId = null)
+ {
+ $qb = $this->createQueryBuilder('e')
+ ->select('e.id');
+
+ if (null !== $userId) {
+ $qb->where('e.user = :userid')->setParameter(':userid', $userId);
+ }
+
+ return $qb->getQuery()->getArrayResult();
+ }
+
/**
* Find all entries by url and owner.
*