1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2019 SURFnet B.V. |
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\Identity\Value; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing; |
22
|
|
|
|
23
|
|
|
class AuthorizedInstitutionCollection |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Mapped on institution, a list of authorizations for the institution relation |
27
|
|
|
* |
28
|
|
|
* @example |
29
|
|
|
* [ |
30
|
|
|
* 'institution-1' => [use_ra, use_raa, select_raa], |
31
|
|
|
* 'institution-2' => [use_ra], |
32
|
|
|
* 'institution-3' => [select_raa], |
33
|
|
|
* ] |
34
|
|
|
* |
35
|
|
|
* @var AuthorityRole[] |
36
|
|
|
*/ |
37
|
|
|
private $authorizations = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param RaListing[] $authorizations |
41
|
|
|
* @return AuthorizedInstitutionCollection |
42
|
|
|
*/ |
43
|
|
|
public static function fromInstitutionAuthorization($authorizations) |
44
|
|
|
{ |
45
|
|
|
$collection = new self(); |
46
|
|
|
|
47
|
|
|
foreach ($authorizations as $authorization) { |
48
|
|
|
$collection->authorizations[(string) $authorization->raInstitution][] = (string) $authorization->role; |
49
|
|
|
} |
50
|
|
|
return $collection; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getAuthorizations() |
54
|
|
|
{ |
55
|
|
|
return $this->authorizations; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|