Completed
Pull Request — develop (#235)
by
unknown
04:07
created

applySelectRaaOptionChangedEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\SelectRaaOptionChangedEvent;
23
use Surfnet\Stepup\Configuration\Event\UseRaaOptionChangedEvent;
24
use Surfnet\Stepup\Configuration\Event\UseRaOptionChangedEvent;
25
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository;
26
27
final class InstitutionAuthorizationProjector extends Projector
28
{
29
    /**
30
     * @var InstitutionAuthorizationRepository
31
     */
32
    private $institutionAuthorizationRepository;
33
34
    public function __construct(
35
        InstitutionAuthorizationRepository $institutionAuthorizationRepository
36
    ) {
37
        $this->institutionAuthorizationRepository = $institutionAuthorizationRepository;
38
    }
39
40
    public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
41
    {
42
        $institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution);
43
        $institutionAuthorization->useRaOption = $event->useRaOption;
44
45
        $this->institutionAuthorizationRepository->save($institutionAuthorization);
46
    }
47
    public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
48
    {
49
        $institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution);
50
        $institutionAuthorization->useRaaOption = $event->useRaaOption;
51
52
        $this->institutionAuthorizationRepository->save($institutionAuthorization);
53
    }
54
    public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
55
    {
56
        $institutionAuthorization = $this->institutionAuthorizationRepository->findAuthorizationOptionsForInstitution($event->institution);
57
        $institutionAuthorization->selectRaaOption = $event->selectRaaOption;
58
59
        $this->institutionAuthorizationRepository->save($institutionAuthorization);
60
    }
61
}
62