You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
<?php |
|
|
|
namespace App\Repository; |
|
|
|
use App\Entity\Endpoint; |
|
use App\Entity\User; |
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
use Doctrine\ORM\Query; |
|
use Symfony\Bridge\Doctrine\RegistryInterface; |
|
|
|
/** |
|
* @method Endpoint|null find($id, $lockMode = null, $lockVersion = null) |
|
* @method Endpoint|null findOneBy(array $criteria, array $orderBy = null) |
|
* @method Endpoint[] findAll() |
|
* @method Endpoint[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
*/ |
|
class EndpointRepository extends ServiceEntityRepository |
|
{ |
|
public function __construct(RegistryInterface $registry) |
|
{ |
|
parent::__construct($registry, Endpoint::class); |
|
} |
|
|
|
/** |
|
* @param User $user |
|
* @param int $streamId |
|
* @return array |
|
* @author Soner Sayakci <shyim@posteo.de> |
|
*/ |
|
public function getEndpoints(User $user, int $streamId) : array |
|
{ |
|
$qb = $this->createQueryBuilder('endpoint') |
|
->leftJoin('endpoint.stream', 'stream') |
|
->where('stream.userId = :userId') |
|
->andWhere('stream.id = :id') |
|
->setParameter('userId', $user->getId()) |
|
->setParameter('id', $streamId) |
|
->getQuery(); |
|
|
|
return $qb->getResult(Query::HYDRATE_ARRAY); |
|
} |
|
}
|
|
|