1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\ApiBundle\Controller; |
20
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Identity\Value\Institution; |
22
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaCandidateQuery; |
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaCandidateService; |
24
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse; |
25
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
26
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
27
|
|
|
use Symfony\Component\HttpFoundation\Request; |
28
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
29
|
|
|
|
30
|
|
|
class RaCandidateController extends Controller |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var RaCandidateService |
34
|
|
|
*/ |
35
|
|
|
private $raCandidateService; |
36
|
|
|
|
37
|
|
|
public function __construct(RaCandidateService $raCandidateService) |
38
|
|
|
{ |
39
|
|
|
$this->raCandidateService = $raCandidateService; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param Institution $institution |
44
|
|
|
* @param Request $request |
45
|
|
|
* @return JsonCollectionResponse |
46
|
|
|
*/ |
47
|
|
|
public function searchAction(Institution $institution, Request $request) |
48
|
|
|
{ |
49
|
|
|
$this->denyAccessUnlessGranted(['ROLE_RA']); |
50
|
|
|
|
51
|
|
|
$query = new RaCandidateQuery(); |
52
|
|
|
$query->institution = $institution; |
53
|
|
|
$query->commonName = $request->get('commonName'); |
54
|
|
|
$query->email = $request->get('email'); |
55
|
|
|
$query->secondFactorTypes = $request->get('secondFactorTypes'); |
|
|
|
|
56
|
|
|
$query->pageNumber = (int) $request->get('p', 1); |
57
|
|
|
|
58
|
|
|
$paginator = $this->raCandidateService->search($query); |
59
|
|
|
|
60
|
|
|
return JsonCollectionResponse::fromPaginator($paginator); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param Request $request |
65
|
|
|
* @return JsonResponse |
66
|
|
|
*/ |
67
|
|
View Code Duplication |
public function getAction(Request $request) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
$this->denyAccessUnlessGranted(['ROLE_RA']); |
70
|
|
|
|
71
|
|
|
$identityId = $request->get('identityId'); |
72
|
|
|
|
73
|
|
|
$raCandidate = $this->raCandidateService->findByIdentityId($identityId); |
74
|
|
|
|
75
|
|
|
if ($raCandidate === null) { |
76
|
|
|
throw new NotFoundHttpException(sprintf("RaCandidate with IdentityId '%s' does not exist", $identityId)); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return new JsonResponse($raCandidate); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..