-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicroPostRepository.php
68 lines (62 loc) · 1.85 KB
/
MicroPostRepository.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace App\Repository;
use App\Entity\MicroPost;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Query\QueryBuilder;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method MicroPost|null find($id, $lockMode = null, $lockVersion = null)
* @method MicroPost|null findOneBy(array $criteria, array $orderBy = null)
* @method MicroPost[] findAll()
* @method MicroPost[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MicroPostRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, MicroPost::class);
}
// /**
// * @return MicroPost[] Returns an array of MicroPost objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->orderBy('m.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?MicroPost
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
/**
* @param Collection $users
*
* @return array
*/
public function findAllByUsers(Collection $users): array
{
$qb = $this->createQueryBuilder('mp');
return $qb->select('mp')
->where('mp.user IN (:following)')
->setParameter('following', $users)
->orderBy('mp.time', 'DESC')
->getQuery()
->getResult();
}
}