wallabag/src/Wallabag/CoreBundle/Repository/TagRepository.php

45 lines
1 KiB
PHP
Raw Normal View History

2015-02-20 16:18:48 +00:00
<?php
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
2015-08-07 16:17:23 +00:00
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
2015-02-20 16:18:48 +00:00
2015-02-20 16:20:12 +00:00
class TagRepository extends EntityRepository
2015-02-20 16:18:48 +00:00
{
2015-08-07 16:17:23 +00:00
/**
* Find Tags.
*
* @param int $userId
2015-08-07 16:17:23 +00:00
*
* @return array
*/
public function findTags($userId)
{
$qb = $this->createQueryBuilder('t')
->where('t.user =:userId')->setParameter('userId', $userId);
$pagerAdapter = new DoctrineORMAdapter($qb);
return new Pagerfanta($pagerAdapter);
}
2015-08-19 09:46:21 +00:00
/**
* Find a tag by its label and its owner.
*
* @param string $label
* @param int $userId
*
* @return Tag|null
*/
public function findOneByLabelAndUserId($label, $userId)
{
return $this->createQueryBuilder('t')
->where('t.label = :label')->setParameter('label', $label)
->andWhere('t.user = :user_id')->setParameter('user_id', $userId)
->getQuery()
->getOneOrNullResult();
}
2015-02-20 16:18:48 +00:00
}