|
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\Projector; |
|
20
|
|
|
|
|
21
|
|
|
use Broadway\ReadModel\Projector; |
|
22
|
|
|
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent; |
|
23
|
|
|
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent; |
|
24
|
|
|
use Surfnet\Stepup\Configuration\Event\ShowRaaContactInformationOptionChangedEvent; |
|
25
|
|
|
use Surfnet\Stepup\Configuration\Event\UseRaLocationsOptionChangedEvent; |
|
26
|
|
|
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption; |
|
27
|
|
|
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption; |
|
28
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions; |
|
29
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository; |
|
30
|
|
|
|
|
31
|
|
|
final class InstitutionConfigurationOptionsProjector extends Projector |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var InstitutionConfigurationOptionsRepository |
|
35
|
|
|
*/ |
|
36
|
|
|
private $repository; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct(InstitutionConfigurationOptionsRepository $repository) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->repository = $repository; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event) |
|
44
|
|
|
{ |
|
45
|
|
|
$institutionConfigurationOptions = InstitutionConfigurationOptions::create( |
|
|
|
|
|
|
46
|
|
|
$event->institution, |
|
47
|
|
|
$event->useRaLocationsOption, |
|
48
|
|
|
$event->showRaaContactInformationOption |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
$this->repository->save($institutionConfigurationOptions); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event) |
|
55
|
|
|
{ |
|
56
|
|
|
$institutionConfigurationOptions = $this->repository->findConfigurationOptionsFor($event->institution); |
|
|
|
|
|
|
57
|
|
|
$institutionConfigurationOptions->useRaLocationsOption = $event->useRaLocationsOption; |
|
58
|
|
|
|
|
59
|
|
|
$this->repository->save($institutionConfigurationOptions); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function applyShowRaaContactInformationOptionChangedEvent(ShowRaaContactInformationOptionChangedEvent $event) |
|
63
|
|
|
{ |
|
64
|
|
|
$institutionConfigurationOptions = $this->repository->findConfigurationOptionsFor($event->institution); |
|
|
|
|
|
|
65
|
|
|
$institutionConfigurationOptions->showRaaContactInformationOption = $event->showRaaContactInformationOption; |
|
66
|
|
|
|
|
67
|
|
|
$this->repository->save($institutionConfigurationOptions); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event) |
|
71
|
|
|
{ |
|
72
|
|
|
$this->repository->removeConfigurationOptionsFor($event->institution); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.