|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2016 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\Configuration\Entity; |
|
20
|
|
|
|
|
21
|
|
|
use JsonSerializable; |
|
22
|
|
|
use Surfnet\Stepup\Configuration\Value\ContactInformation; |
|
23
|
|
|
use Surfnet\Stepup\Configuration\Value\Institution; |
|
24
|
|
|
use Surfnet\Stepup\Configuration\Value\Location; |
|
25
|
|
|
use Surfnet\Stepup\Configuration\Value\RaLocationName; |
|
26
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException; |
|
27
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @ORM\Entity( |
|
31
|
|
|
* repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository" |
|
32
|
|
|
* ) |
|
33
|
|
|
* @ORM\Table( |
|
34
|
|
|
* indexes={ |
|
35
|
|
|
* @ORM\Index(name="idx_ra_location_institution", columns={"institution"}) |
|
36
|
|
|
* } |
|
37
|
|
|
* ) |
|
38
|
|
|
*/ |
|
39
|
|
|
class RaLocation implements JsonSerializable |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* @ORM\Id |
|
43
|
|
|
* @ORM\Column(length=36) |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
public $raLocationId; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @ORM\Column(type="stepup_configuration_location") |
|
51
|
|
|
* |
|
52
|
|
|
* @var Institution |
|
53
|
|
|
*/ |
|
54
|
|
|
public $institution; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @ORM\Column(type="stepup_ra_location_name") |
|
58
|
|
|
* |
|
59
|
|
|
* @var RaLocationName |
|
60
|
|
|
*/ |
|
61
|
|
|
public $raLocationName; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @ORM\Column(type="stepup_configuration_location") |
|
65
|
|
|
* |
|
66
|
|
|
* @var Location |
|
67
|
|
|
*/ |
|
68
|
|
|
public $location; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @ORM\Column(type="stepup_configuration_contact_information") |
|
72
|
|
|
* |
|
73
|
|
|
* @var ContactInformation |
|
74
|
|
|
*/ |
|
75
|
|
|
public $contactInformation; |
|
76
|
|
|
|
|
77
|
|
|
public static function create( |
|
78
|
|
|
$raLocationId, |
|
79
|
|
|
Institution $institution, |
|
80
|
|
|
RaLocationName $raLocationName, |
|
81
|
|
|
Location $location, |
|
82
|
|
|
ContactInformation $contactInformation |
|
83
|
|
|
) { |
|
84
|
|
|
if (!is_string($raLocationId)) { |
|
85
|
|
|
throw InvalidArgumentException::invalidType('string', 'raLocationId', $raLocationId); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$raLocation = new self; |
|
89
|
|
|
|
|
90
|
|
|
$raLocation->raLocationId = $raLocationId; |
|
91
|
|
|
$raLocation->institution = $institution; |
|
92
|
|
|
$raLocation->raLocationName = $raLocationName; |
|
93
|
|
|
$raLocation->location = $location; |
|
94
|
|
|
$raLocation->contactInformation = $contactInformation; |
|
95
|
|
|
|
|
96
|
|
|
return $raLocation; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function jsonSerialize() |
|
100
|
|
|
{ |
|
101
|
|
|
return [ |
|
102
|
|
|
'ra_location_id' => $this->raLocationId, |
|
103
|
|
|
'institution' => $this->institution, |
|
104
|
|
|
'ra_location_name' => $this->raLocationName, |
|
105
|
|
|
'location' => $this->location, |
|
106
|
|
|
'contact_information' => $this->contactInformation, |
|
107
|
|
|
]; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|