|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2017 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\MiddlewareBundle\Migrations\InstitutionConfiguration; |
|
20
|
|
|
|
|
21
|
|
|
use Rhumsaa\Uuid\Uuid; |
|
22
|
|
|
use Surfnet\Stepup\Configuration\Entity\RaLocation; |
|
23
|
|
|
use Surfnet\Stepup\Configuration\Value\Institution; |
|
24
|
|
|
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption; |
|
25
|
|
|
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption; |
|
26
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\AddRaLocationCommand; |
|
27
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\CreateInstitutionConfigurationCommand; |
|
28
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ReconfigureInstitutionConfigurationOptionsCommand; |
|
|
|
|
|
|
29
|
|
|
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\RemoveInstitutionConfigurationByUnnormalizedIdCommand; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
final class MappedInstitutionConfiguration |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var Institution |
|
35
|
|
|
*/ |
|
36
|
|
|
private $institution; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var ShowRaaContactInformationOption |
|
40
|
|
|
*/ |
|
41
|
|
|
private $showRaaContactInformationOption; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var UseRaLocationsOption |
|
45
|
|
|
*/ |
|
46
|
|
|
private $useRaLocationsOption; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var array|RaLocation[] |
|
50
|
|
|
*/ |
|
51
|
|
|
private $raLocations; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param Institution $institution |
|
55
|
|
|
* @param UseRaLocationsOption $useRaLocationsOption |
|
56
|
|
|
* @param ShowRaaContactInformationOption $showRaaContactInformationOption |
|
57
|
|
|
* @param RaLocation[] $raLocations |
|
58
|
|
|
*/ |
|
59
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
60
|
|
|
Institution $institution, |
|
61
|
|
|
UseRaLocationsOption $useRaLocationsOption, |
|
62
|
|
|
ShowRaaContactInformationOption $showRaaContactInformationOption, |
|
|
|
|
|
|
63
|
|
|
array $raLocations |
|
64
|
|
|
) { |
|
65
|
|
|
$this->institution = $institution; |
|
66
|
|
|
$this->showRaaContactInformationOption = $showRaaContactInformationOption; |
|
67
|
|
|
$this->useRaLocationsOption = $useRaLocationsOption; |
|
68
|
|
|
$this->raLocations = $raLocations; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return RemoveInstitutionConfigurationByUnnormalizedIdCommand |
|
73
|
|
|
*/ |
|
74
|
|
View Code Duplication |
public function inferRemoveInstitutionConfigurationByIdCommand() |
|
|
|
|
|
|
75
|
|
|
{ |
|
76
|
|
|
$command = new RemoveInstitutionConfigurationByUnnormalizedIdCommand(); |
|
77
|
|
|
$command->UUID = (string) Uuid::uuid4(); |
|
78
|
|
|
$command->institution = $this->institution->getInstitution(); |
|
79
|
|
|
|
|
80
|
|
|
return $command; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return CreateInstitutionConfigurationCommand |
|
85
|
|
|
*/ |
|
86
|
|
View Code Duplication |
public function inferCreateInstitutionConfigurationCommand() |
|
|
|
|
|
|
87
|
|
|
{ |
|
88
|
|
|
$command = new CreateInstitutionConfigurationCommand(); |
|
89
|
|
|
$command->UUID = (string) Uuid::uuid4(); |
|
90
|
|
|
$command->institution = $this->institution->getInstitution(); |
|
91
|
|
|
|
|
92
|
|
|
return $command; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return ReconfigureInstitutionConfigurationOptionsCommand |
|
97
|
|
|
*/ |
|
98
|
|
|
public function inferReconfigureInstitutionConfigurationCommand() |
|
99
|
|
|
{ |
|
100
|
|
|
$command = new ReconfigureInstitutionConfigurationOptionsCommand(); |
|
101
|
|
|
$command->UUID = (string) Uuid::uuid4(); |
|
102
|
|
|
$command->institution = $this->institution->getInstitution(); |
|
103
|
|
|
$command->useRaLocationsOption = $this->useRaLocationsOption->isEnabled(); |
|
104
|
|
|
$command->showRaaContactInformationOption = $this->showRaaContactInformationOption->isEnabled(); |
|
105
|
|
|
|
|
106
|
|
|
return $command; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return AddRaLocationCommand[] |
|
111
|
|
|
*/ |
|
112
|
|
|
public function inferAddRaLocationCommands() |
|
113
|
|
|
{ |
|
114
|
|
|
$commands = []; |
|
115
|
|
|
$institution = $this->institution->getInstitution(); |
|
116
|
|
|
|
|
117
|
|
|
foreach ($this->raLocations as $raLocation) { |
|
118
|
|
|
$command = new AddRaLocationCommand(); |
|
119
|
|
|
$command->UUID = (string) Uuid::uuid4(); |
|
120
|
|
|
$command->institution = $institution; |
|
121
|
|
|
$command->raLocationId = $raLocation->getId()->getRaLocationId(); |
|
122
|
|
|
$command->raLocationName = $raLocation->getName()->getRaLocationName(); |
|
123
|
|
|
$command->contactInformation = $raLocation->getContactInformation()->getContactInformation(); |
|
124
|
|
|
$command->location = $raLocation->getLocation()->getLocation(); |
|
125
|
|
|
|
|
126
|
|
|
$commands[] = $command; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
return $commands; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.