aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 960b682d..37fc1000 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -9,6 +9,7 @@ use Pagerfanta\Adapter\DoctrineORMAdapter;
9use Pagerfanta\Pagerfanta; 9use Pagerfanta\Pagerfanta;
10use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Helper\UrlHasher;
12 13
13class EntryRepository extends EntityRepository 14class EntryRepository extends EntityRepository
14{ 15{
@@ -349,7 +350,7 @@ class EntryRepository extends EntityRepository
349 public function findByUrlAndUserId($url, $userId) 350 public function findByUrlAndUserId($url, $userId)
350 { 351 {
351 return $this->findByHashedUrlAndUserId( 352 return $this->findByHashedUrlAndUserId(
352 hash('sha1', $url), // XXX: the hash logic would better be in a separate util to avoid duplication with GenerateUrlHashesCommand::generateHashedUrls 353 UrlHasher::hashUrl($url),
353 $userId); 354 $userId);
354 } 355 }
355 356
@@ -507,6 +508,32 @@ class EntryRepository extends EntityRepository
507 } 508 }
508 509
509 /** 510 /**
511 * Inject a UrlHasher.
512 *
513 * @param UrlHasher $hasher
514 */
515 public function setUrlHasher(UrlHasher $hasher)
516 {
517 $this->urlHasher = $hasher;
518 }
519
520 /**
521 * Get the UrlHasher, or create a default one if not injected.
522 *
523 * XXX: the default uses the default hash algorithm
524 *
525 * @return UrlHasher
526 */
527 protected function getUrlHasher()
528 {
529 if (!isset($this->urlHasher)) {
530 $this->setUrlHasher(new UrlHasher());
531 }
532
533 return $this->urlHasher;
534 }
535
536 /**
510 * Return a query builder to be used by other getBuilderFor* method. 537 * Return a query builder to be used by other getBuilderFor* method.
511 * 538 *
512 * @param int $userId 539 * @param int $userId