Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 15 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
||
| DoctrineUserSetRepository | |
0.00% |
0 / 14 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
||
| __construct | |
0.00% |
0 / 1 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| findByUserAndExternalIds | |
0.00% |
0 / 13 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| 1 | <?php |
| 2 | |
| 3 | namespace App\CollectionManagement\Infrastructure\Persistence\Doctrine\Repository; |
| 4 | |
| 5 | use App\CollectionManagement\Domain\Model\Local\Set; |
| 6 | use App\CollectionManagement\Domain\Model\Local\UserSet; |
| 7 | use App\CollectionManagement\Domain\Model\UserSetCollection; |
| 8 | use App\CollectionManagement\Infrastructure\Persistence\Doctrine\Entity\DoctrineUserSet; |
| 9 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
| 10 | use Doctrine\Persistence\ManagerRegistry; |
| 11 | use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; |
| 12 | |
| 13 | /** |
| 14 | * @author W.Zwertvaegher |
| 15 | * @extends ServiceEntityRepository<Set> |
| 16 | */ |
| 17 | #[Autoconfigure] |
| 18 | class DoctrineUserSetRepository extends ServiceEntityRepository implements \App\CollectionManagement\Domain\Port\Driven\UserSetRepository |
| 19 | { |
| 20 | public function __construct(ManagerRegistry $managerRegistry) |
| 21 | { |
| 22 | parent::__construct($managerRegistry, Set::class); |
| 23 | } |
| 24 | |
| 25 | public function findByUserAndExternalIds(string $userId, array $externalIds): UserSetCollection |
| 26 | { |
| 27 | return new UserSetCollection( |
| 28 | array_map( |
| 29 | fn (DoctrineUserSet $doctrineUserSet): UserSet => $doctrineUserSet->toDomain(), |
| 30 | $this->createQueryBuilder('us') |
| 31 | ->join('us.set', 's') |
| 32 | ->where('us.user = :userId') |
| 33 | ->andWhere('s.externalId IN (:externalIds)') |
| 34 | ->setParameter('userId', $userId) |
| 35 | ->setParameter('externalIds', $externalIds) |
| 36 | ->getQuery() |
| 37 | ->getResult() |
| 38 | ) |
| 39 | ); |
| 40 | } |
| 41 | } |