1 | <?php |
||
38 | class RaCandidateRepository extends EntityRepository |
||
39 | { |
||
40 | /** |
||
41 | * @var InstitutionAuthorizationRepositoryFilter |
||
42 | */ |
||
43 | private $authorizationRepositoryFilter; |
||
44 | |||
45 | public function __construct( |
||
46 | EntityManager $em, |
||
47 | Mapping\ClassMetadata $class, |
||
48 | InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter |
||
49 | ) { |
||
50 | parent::__construct($em, $class); |
||
51 | $this->authorizationRepositoryFilter = $authorizationRepositoryFilter; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param RaCandidate $raCandidate |
||
56 | * @return void |
||
57 | */ |
||
58 | public function merge(RaCandidate $raCandidate) |
||
59 | { |
||
60 | $raCandidate = $this->getEntityManager()->merge($raCandidate); |
||
61 | $this->getEntityManager()->persist($raCandidate); |
||
62 | $this->getEntityManager()->flush(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param IdentityId $identityId |
||
67 | * @return void |
||
68 | */ |
||
69 | public function removeByIdentityId(IdentityId $identityId) |
||
80 | |||
81 | /** |
||
82 | * @param Institution $institution |
||
83 | * @param InstitutionCollection $raInstitutions |
||
84 | * @return void |
||
85 | */ |
||
86 | public function removeInstitutionsNotInList(Institution $institution, InstitutionCollection $raInstitutions) |
||
103 | |||
104 | /** |
||
105 | * @param Institution $raInstitution |
||
106 | * @return void |
||
107 | */ |
||
108 | public function removeByRaInstitution(Institution $raInstitution) |
||
123 | |||
124 | /** |
||
125 | * @param IdentityId $identityId |
||
126 | * @param Institution $raInstitution |
||
127 | * @return void |
||
128 | */ |
||
129 | public function removeByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution) |
||
140 | |||
141 | /** |
||
142 | * @param string[] $nameIds |
||
143 | * @return void |
||
144 | */ |
||
145 | public function removeByNameIds($nameIds) |
||
156 | |||
157 | /** |
||
158 | * @param RaCandidateQuery $query |
||
159 | * @return \Doctrine\ORM\Query |
||
160 | */ |
||
161 | public function createSearchQuery(RaCandidateQuery $query) |
||
162 | { |
||
163 | $queryBuilder = $this->createQueryBuilder('rac'); |
||
164 | |||
165 | // Modify query to filter on authorization |
||
166 | $this->authorizationRepositoryFilter->filterCandidate( |
||
167 | $queryBuilder, |
||
168 | $query->authorizationContext->getActorInstitution(), |
||
169 | 'rac.identityId', |
||
170 | 'rac.raInstitution', |
||
171 | 'iac' |
||
172 | ); |
||
173 | |||
174 | if ($query->institution) { |
||
175 | $queryBuilder |
||
176 | ->andWhere('rac.institution = :institution') |
||
177 | ->setParameter('institution', $query->institution); |
||
178 | } |
||
179 | |||
180 | if ($query->commonName) { |
||
181 | $queryBuilder |
||
182 | ->andWhere('MATCH_AGAINST(rac.commonName, :commonName) > 0') |
||
183 | ->setParameter('commonName', $query->commonName); |
||
184 | } |
||
185 | |||
186 | if ($query->email) { |
||
187 | $queryBuilder |
||
188 | ->andWhere('MATCH_AGAINST(rac.email, :email) > 0') |
||
189 | ->setParameter('email', $query->email); |
||
190 | } |
||
191 | |||
192 | if (!empty($query->secondFactorTypes)) { |
||
193 | $queryBuilder |
||
194 | ->innerJoin(VettedSecondFactor::class, 'vsf', Join::WITH, 'rac.identityId = vsf.identityId') |
||
195 | ->andWhere('vsf.type IN (:secondFactorTypes)') |
||
196 | ->setParameter('secondFactorTypes', $query->secondFactorTypes); |
||
197 | } |
||
198 | |||
199 | return $queryBuilder->getQuery(); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * @param string[] $sraaList |
||
204 | * @return RaCandidate[] |
||
205 | */ |
||
206 | public function findByNameIds(array $sraaList) |
||
214 | |||
215 | /** |
||
216 | * @param string $identityId |
||
217 | * @return null|RaCandidate |
||
218 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
219 | */ |
||
220 | public function findByIdentityId($identityId) |
||
228 | |||
229 | /** |
||
230 | * @param string $identityId |
||
231 | * @param Institution $raInstitution |
||
232 | * @return null|RaCandidate |
||
233 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
234 | */ |
||
235 | public function findByIdentityIdAndRaInstitution($identityId, Institution $raInstitution) |
||
245 | |||
246 | |||
247 | /** |
||
248 | * @param string $identityId |
||
249 | * @param Institution $raInstitution |
||
250 | * @return RaCandidate[] |
||
251 | */ |
||
252 | public function findAllRaasByIdentityIdAndRaInstitution($identityId, Institution $raInstitution) |
||
270 | |||
271 | /** |
||
272 | * @param Institution $raInstitution |
||
273 | * @return ArrayCollection|RaCandidate[] |
||
|
|||
274 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
275 | */ |
||
276 | public function findByRaInstitution(Institution $raInstitution) |
||
284 | } |
||
285 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.