@@ 27-48 (lines=22) @@ | ||
24 | use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException; |
|
25 | use Symfony\Component\HttpFoundation\Request; |
|
26 | ||
27 | class ActorInstitutionParamConverter implements ParamConverterInterface |
|
28 | { |
|
29 | public function apply(Request $request, ParamConverter $configuration) |
|
30 | { |
|
31 | $query = $request->query; |
|
32 | $institution = $query->get('actorInstitution', false); |
|
33 | ||
34 | if ($institution === false) { |
|
35 | throw new BadApiRequestException(['This API-call MUST include the actorInstitution as get parameter']); |
|
36 | } |
|
37 | ||
38 | $query->remove('actorInstitution'); |
|
39 | ||
40 | $request->attributes->set('actorInstitution', new Institution($institution)); |
|
41 | } |
|
42 | ||
43 | public function supports(ParamConverter $configuration) |
|
44 | { |
|
45 | return $configuration->getName() === 'actorInstitution' |
|
46 | && $configuration->getClass() === 'Surfnet\Stepup\Identity\Value\Institution'; |
|
47 | } |
|
48 | } |
|
49 |
@@ 27-48 (lines=22) @@ | ||
24 | use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException; |
|
25 | use Symfony\Component\HttpFoundation\Request; |
|
26 | ||
27 | class InstitutionParamConverter implements ParamConverterInterface |
|
28 | { |
|
29 | public function apply(Request $request, ParamConverter $configuration) |
|
30 | { |
|
31 | $query = $request->query; |
|
32 | $institution = $query->get('institution', false); |
|
33 | ||
34 | if ($institution === false) { |
|
35 | throw new BadApiRequestException(['This API-call MUST include the institution as get parameter']); |
|
36 | } |
|
37 | ||
38 | $query->remove('institution'); |
|
39 | ||
40 | $request->attributes->set('institution', new Institution($institution)); |
|
41 | } |
|
42 | ||
43 | public function supports(ParamConverter $configuration) |
|
44 | { |
|
45 | return $configuration->getName() === 'institution' |
|
46 | && $configuration->getClass() === 'Surfnet\Stepup\Identity\Value\Institution'; |
|
47 | } |
|
48 | } |
|
49 |