X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FAnnotationBundle%2FRepository%2FAnnotationRepository.php;h=014c29b65f97b39758880c894106652dbcf830d3;hb=f808b01692a835673f328d7221ba8c212caa9b61;hp=52989bcf8a780df11bacedf19dc3edea80438566;hpb=b0de88f75dead50385e80e3897dc3913a971b91e;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index 52989bcf..014c29b6 100644 --- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php +++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php @@ -9,22 +9,6 @@ use Doctrine\ORM\EntityRepository; */ class AnnotationRepository extends EntityRepository { - /** - * Return a query builder to used by other getBuilderFor* method. - * - * @param int $userId - * - * @return QueryBuilder - */ - private function getBuilderByUser($userId) - { - return $this->createQueryBuilder('a') - ->leftJoin('a.user', 'u') - ->andWhere('u.id = :userId')->setParameter('userId', $userId) - ->orderBy('a.id', 'desc') - ; - } - /** * Retrieves all annotations for a user. * @@ -50,7 +34,8 @@ class AnnotationRepository extends EntityRepository { return $this->createQueryBuilder('a') ->andWhere('a.id = :annotationId')->setParameter('annotationId', $annotationId) - ->getQuery()->getSingleResult() + ->getQuery() + ->getSingleResult() ; } @@ -67,7 +52,8 @@ class AnnotationRepository extends EntityRepository return $this->createQueryBuilder('a') ->where('a.entry = :entryId')->setParameter('entryId', $entryId) ->andwhere('a.user = :userId')->setParameter('userId', $userId) - ->getQuery()->getResult() + ->getQuery() + ->getResult() ; } @@ -120,4 +106,37 @@ class AnnotationRepository extends EntityRepository ->setParameter('userId', $userId) ->execute(); } + + /** + * Find all annotations related to archived entries. + * + * @param $userId + * + * @return mixed + */ + public function findAllArchivedEntriesByUser($userId) + { + return $this->createQueryBuilder('a') + ->leftJoin('a.entry', 'e') + ->where('a.user = :userid')->setParameter(':userid', $userId) + ->andWhere('e.isArchived = true') + ->getQuery() + ->getResult(); + } + + /** + * Return a query builder to used by other getBuilderFor* method. + * + * @param int $userId + * + * @return QueryBuilder + */ + private function getBuilderByUser($userId) + { + return $this->createQueryBuilder('a') + ->leftJoin('a.user', 'u') + ->andWhere('u.id = :userId')->setParameter('userId', $userId) + ->orderBy('a.id', 'desc') + ; + } }