Completed
Push — feature/self-vet ( 44f529 )
by Michiel
02:46
created

InstitutionConfiguration::configureSelfVetOption()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
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\Stepup\Configuration;
20
21
use Broadway\EventSourcing\EventSourcedAggregateRoot;
22
use Surfnet\Stepup\Configuration\Api\InstitutionConfiguration as InstitutionConfigurationInterface;
23
use Surfnet\Stepup\Configuration\Entity\RaLocation;
24
use Surfnet\Stepup\Configuration\Event\AllowedSecondFactorListUpdatedEvent;
25
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
26
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
27
use Surfnet\Stepup\Configuration\Event\NumberOfTokensPerIdentityOptionChangedEvent;
28
use Surfnet\Stepup\Configuration\Event\RaLocationAddedEvent;
29
use Surfnet\Stepup\Configuration\Event\RaLocationContactInformationChangedEvent;
30
use Surfnet\Stepup\Configuration\Event\RaLocationRelocatedEvent;
31
use Surfnet\Stepup\Configuration\Event\RaLocationRemovedEvent;
32
use Surfnet\Stepup\Configuration\Event\RaLocationRenamedEvent;
33
use Surfnet\Stepup\Configuration\Event\SelectRaaOptionChangedEvent;
34
use Surfnet\Stepup\Configuration\Event\SelfVetOptionChangedEvent;
35
use Surfnet\Stepup\Configuration\Event\ShowRaaContactInformationOptionChangedEvent;
36
use Surfnet\Stepup\Configuration\Event\UseRaaOptionChangedEvent;
37
use Surfnet\Stepup\Configuration\Event\UseRaLocationsOptionChangedEvent;
38
use Surfnet\Stepup\Configuration\Event\UseRaOptionChangedEvent;
39
use Surfnet\Stepup\Configuration\Event\VerifyEmailOptionChangedEvent;
40
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
41
use Surfnet\Stepup\Configuration\Value\ContactInformation;
42
use Surfnet\Stepup\Configuration\Value\Institution;
43
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
44
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
45
use Surfnet\Stepup\Configuration\Value\Location;
46
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
47
use Surfnet\Stepup\Configuration\Value\RaLocationId;
48
use Surfnet\Stepup\Configuration\Value\RaLocationList;
49
use Surfnet\Stepup\Configuration\Value\RaLocationName;
50
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
51
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
52
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
53
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
54
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
55
use Surfnet\Stepup\Exception\DomainException;
56
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
57
58
/**
59
 * InstitutionConfiguration aggregate root
60
 *
61
 * Some things to know about this aggregate:
62
 *
63
 * 1. The aggregate is instantiated by InstitutionConfigurationCommandHandler by calling the
64
 *    handleReconfigureInstitutionConfigurationOptionsCommand method. It does so, not by using the projections to build
65
 *    the aggregate but by playing the events onto the aggregate.
66
 * 2. If one of the configuration options should be nullable, take a look at the applyUseRaOptionChangedEvent doc block
67
 *
68
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects) Events and value objects
69
 * @SuppressWarnings(PHPMD.TooManyMethods) AggregateRoot
70
 * @SuppressWarnings(PHPMD.TooManyPublicMethods) AggregateRoot
71
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) AggregateRoot
72
 */
73
class InstitutionConfiguration extends EventSourcedAggregateRoot implements InstitutionConfigurationInterface
74
{
75
    /**
76
     * @var InstitutionConfigurationId
77
     */
78
    private $institutionConfigurationId;
79
80
    /**
81
     * @var Institution
82
     */
83
    private $institution;
84
85
    /**
86
     * @var RaLocationList
87
     */
88
    private $raLocations;
89
90
    /**
91
     * @var UseRaLocationsOption
92
     */
93
    private $useRaLocationsOption;
94
95
    /**
96
     * @var ShowRaaContactInformationOption
97
     */
98
    private $showRaaContactInformationOption;
99
100
    /**
101
     * @var VerifyEmailOption
102
     */
103
    private $verifyEmailOption;
104
105
    /**
106
     * @var NumberOfTokensPerIdentityOption
107
     */
108
    private $numberOfTokensPerIdentityOption;
109
110
    /**
111
     * @var SelfVetOption
112
     */
113
    private $selfVetOption;
114
115
    /**
116
     * @var InstitutionAuthorizationOption
117
     */
118
    private $useRaOption;
119
120
    /**
121
     * @var InstitutionAuthorizationOption
122
     */
123
124
    private $useRaaOption;
125
126
    /**
127
     * @var InstitutionAuthorizationOption
128
     */
129
    private $selectRaaOption;
130
131
    /**
132
     * @var AllowedSecondFactorList
133
     */
134
    private $allowedSecondFactorList;
135
136
    /**
137
     * @var boolean
138
     */
139
    private $isMarkedAsDestroyed;
140
141
    /**
142
     * @param InstitutionConfigurationId $institutionConfigurationId
143
     * @param Institution $institution
144
     * @return InstitutionConfiguration
145
     */
146
    public static function create(InstitutionConfigurationId $institutionConfigurationId, Institution $institution)
147
    {
148
        $institutionConfiguration = new self;
149
        $institutionConfiguration->apply(
150
            new NewInstitutionConfigurationCreatedEvent(
0 ignored issues
show
Bug introduced by
The call to NewInstitutionConfigurat...tedEvent::__construct() misses a required argument $selfVetOption.

This check looks for function calls that miss required arguments.

Loading history...
151
                $institutionConfigurationId,
152
                $institution,
153
                UseRaLocationsOption::getDefault(),
154
                ShowRaaContactInformationOption::getDefault(),
155
                VerifyEmailOption::getDefault(),
156
                NumberOfTokensPerIdentityOption::getDefault()
157
            )
158
        );
159
        $institutionConfiguration->apply(new AllowedSecondFactorListUpdatedEvent(
160
            $institutionConfigurationId,
161
            $institution,
162
            AllowedSecondFactorList::blank()
163
        ));
164
        $institutionConfiguration->apply(
165
            new UseRaOptionChangedEvent(
166
                $institutionConfigurationId,
167
                $institution,
168
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
169
            )
170
        );
171
        $institutionConfiguration->apply(
172
            new UseRaaOptionChangedEvent(
173
                $institutionConfigurationId,
174
                $institution,
175
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
176
            )
177
        );
178
        $institutionConfiguration->apply(
179
            new SelectRaaOptionChangedEvent(
180
                $institutionConfigurationId,
181
                $institution,
182
                InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
183
            )
184
        );
185
186
        return $institutionConfiguration;
187
    }
188
189
    /**
190
     * @return InstitutionConfiguration
191
     */
192
    public function rebuild()
193
    {
194
        // We can only rebuild a destroyed InstitutionConfiguration, all other cases are not valid
195
        if ($this->isMarkedAsDestroyed !== true) {
196
            throw new DomainException('Cannot rebuild InstitutionConfiguration as it has not been destroyed');
197
        }
198
199
        $this->apply(
200
            new NewInstitutionConfigurationCreatedEvent(
0 ignored issues
show
Bug introduced by
The call to NewInstitutionConfigurat...tedEvent::__construct() misses a required argument $selfVetOption.

This check looks for function calls that miss required arguments.

Loading history...
201
                $this->institutionConfigurationId,
202
                $this->institution,
203
                UseRaLocationsOption::getDefault(),
204
                ShowRaaContactInformationOption::getDefault(),
205
                VerifyEmailOption::getDefault(),
206
                NumberOfTokensPerIdentityOption::getDefault()
207
            )
208
        );
209
        $this->apply(new AllowedSecondFactorListUpdatedEvent(
210
            $this->institutionConfigurationId,
211
            $this->institution,
212
            AllowedSecondFactorList::blank()
213
        ));
214
        $this->apply(
215
            new UseRaOptionChangedEvent(
216
                $this->institutionConfigurationId,
217
                $this->institution,
218
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
219
            )
220
        );
221
        $this->apply(
222
            new UseRaaOptionChangedEvent(
223
                $this->institutionConfigurationId,
224
                $this->institution,
225
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
226
            )
227
        );
228
        $this->apply(
229
            new SelectRaaOptionChangedEvent(
230
                $this->institutionConfigurationId,
231
                $this->institution,
232
                InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
233
            )
234
        );
235
236
        return $this;
237
    }
238
239
    final public function __construct()
240
    {
241
    }
242
243
    public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption)
244
    {
245
        if ($this->useRaLocationsOption->equals($useRaLocationsOption)) {
246
            return;
247
        }
248
249
        $this->apply(
250
            new UseRaLocationsOptionChangedEvent(
251
                $this->institutionConfigurationId,
252
                $this->institution,
253
                $useRaLocationsOption
254
            )
255
        );
256
    }
257
258
    public function configureShowRaaContactInformationOption(ShowRaaContactInformationOption $showRaaContactInformationOption)
259
    {
260
        if ($this->showRaaContactInformationOption->equals($showRaaContactInformationOption)) {
261
            return;
262
        }
263
264
        $this->apply(
265
            new ShowRaaContactInformationOptionChangedEvent(
266
                $this->institutionConfigurationId,
267
                $this->institution,
268
                $showRaaContactInformationOption
269
            )
270
        );
271
    }
272
273
    public function configureVerifyEmailOption(VerifyEmailOption $verifyEmailOption)
274
    {
275
        if ($this->verifyEmailOption->equals($verifyEmailOption)) {
276
            return;
277
        }
278
279
        $this->apply(
280
            new VerifyEmailOptionChangedEvent(
281
                $this->institutionConfigurationId,
282
                $this->institution,
283
                $verifyEmailOption
284
            )
285
        );
286
    }
287
288
    public function configureNumberOfTokensPerIdentityOption(
289
        NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption
290
    ) {
291
        if ($this->numberOfTokensPerIdentityOption->equals($numberOfTokensPerIdentityOption)) {
292
            return;
293
        }
294
295
        $this->apply(
296
            new NumberOfTokensPerIdentityOptionChangedEvent(
297
                $this->institutionConfigurationId,
298
                $this->institution,
299
                $numberOfTokensPerIdentityOption
300
            )
301
        );
302
    }
303
304
    public function configureSelfVetOption(SelfVetOption $selfVetOption)
305
    {
306
        if ($this->selfVetOption->equals($selfVetOption)) {
307
            return;
308
        }
309
310
        $this->apply(
311
            new SelfVetOptionChangedEvent(
312
                $this->institutionConfigurationId,
313
                $this->institution,
314
                $selfVetOption
315
            )
316
        );
317
    }
318
319 View Code Duplication
    public function updateUseRaOption(InstitutionAuthorizationOption $useRaOption)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
320
    {
321
        if ($this->useRaOption !== null
322
            && $this->useRaOption->equals($useRaOption)
323
        ) {
324
            return;
325
        }
326
327
        $this->apply(
328
            new UseRaOptionChangedEvent(
329
                $this->institutionConfigurationId,
330
                $this->institution,
331
                $useRaOption
332
            )
333
        );
334
    }
335
336 View Code Duplication
    public function updateUseRaaOption(InstitutionAuthorizationOption $useRaaOption)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
337
    {
338
        if ($this->useRaaOption !== null
339
            && $this->useRaaOption->equals($useRaaOption)
340
        ) {
341
            return;
342
        }
343
344
        $this->apply(
345
            new UseRaaOptionChangedEvent(
346
                $this->institutionConfigurationId,
347
                $this->institution,
348
                $useRaaOption
349
            )
350
        );
351
    }
352
353 View Code Duplication
    public function updateSelectRaaOption(InstitutionAuthorizationOption $selectRaaOption)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
354
    {
355
        if ($this->selectRaaOption !== null
356
            && $this->selectRaaOption->equals($selectRaaOption)
357
        ) {
358
            return;
359
        }
360
361
        $this->apply(
362
            new SelectRaaOptionChangedEvent(
363
                $this->institutionConfigurationId,
364
                $this->institution,
365
                $selectRaaOption
366
            )
367
        );
368
    }
369
370
    public function updateAllowedSecondFactorList(AllowedSecondFactorList $allowedSecondFactorList)
371
    {
372
        // AllowedSecondFactorList can be null for InstitutionConfigurations for which this functionality did not exist
373
        if ($this->allowedSecondFactorList !== null
374
            && $this->allowedSecondFactorList->equals($allowedSecondFactorList)
375
        ) {
376
            return;
377
        }
378
379
        $this->apply(
380
            new AllowedSecondFactorListUpdatedEvent(
381
                $this->institutionConfigurationId,
382
                $this->institution,
383
                $allowedSecondFactorList
384
            )
385
        );
386
    }
387
388
    /**
389
     * @param RaLocationId $raLocationId
390
     * @param RaLocationName $raLocationName
391
     * @param Location $location
392
     * @param ContactInformation $contactInformation
393
     */
394
    public function addRaLocation(
395
        RaLocationId $raLocationId,
396
        RaLocationName $raLocationName,
397
        Location $location,
398
        ContactInformation $contactInformation
399
    ) {
400 View Code Duplication
        if ($this->raLocations->containsWithId($raLocationId)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
401
            throw new DomainException(sprintf(
402
                'Cannot add RaLocation with RaLocationId "%s" to RaLocations of InstitutionConfiguration "%s":'
403
                . ' it is already present',
404
                $raLocationId,
405
                $this->getAggregateRootId()
406
            ));
407
        }
408
409
        $this->apply(new RaLocationAddedEvent(
410
            $this->institutionConfigurationId,
411
            $this->institution,
412
            $raLocationId,
413
            $raLocationName,
414
            $location,
415
            $contactInformation
416
        ));
417
    }
418
419
    /**
420
     * @param RaLocationId $raLocationId
421
     * @param RaLocationName $raLocationName
422
     * @param Location $location
423
     * @param ContactInformation $contactInformation
424
     */
425
    public function changeRaLocation(
426
        RaLocationId $raLocationId,
427
        RaLocationName $raLocationName,
428
        Location $location,
429
        ContactInformation $contactInformation
430
    ) {
431 View Code Duplication
        if (!$this->raLocations->containsWithId($raLocationId)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
432
            throw new DomainException(sprintf(
433
                'Cannot change RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
434
                . ' it is not present',
435
                $raLocationId,
436
                $this->getAggregateRootId()
437
            ));
438
        }
439
440
        $raLocation = $this->raLocations->getById($raLocationId);
441
442
        if (!$raLocation->getName()->equals($raLocationName)) {
443
            $this->apply(
444
                new RaLocationRenamedEvent($this->institutionConfigurationId, $raLocationId, $raLocationName)
445
            );
446
        }
447
        if (!$raLocation->getLocation()->equals($location)) {
448
            $this->apply(
449
                new RaLocationRelocatedEvent($this->institutionConfigurationId, $raLocationId, $location)
450
            );
451
        }
452
        if (!$raLocation->getContactInformation()->equals($contactInformation)) {
453
            $this->apply(
454
                new RaLocationContactInformationChangedEvent(
455
                    $this->institutionConfigurationId,
456
                    $raLocationId,
457
                    $contactInformation
458
                )
459
            );
460
        }
461
    }
462
463
    /**
464
     * @param RaLocationId $raLocationId
465
     */
466
    public function removeRaLocation(RaLocationId $raLocationId)
467
    {
468 View Code Duplication
        if (!$this->raLocations->containsWithId($raLocationId)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
469
            throw new DomainException(sprintf(
470
                'Cannot remove RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
471
                . ' it is not present',
472
                $raLocationId,
473
                $this->getAggregateRootId()
474
            ));
475
        }
476
477
        $this->apply(new RaLocationRemovedEvent($this->institutionConfigurationId, $raLocationId));
478
    }
479
480
    /**
481
     * @return void
482
     */
483
    public function destroy()
484
    {
485
        $this->apply(new InstitutionConfigurationRemovedEvent($this->institutionConfigurationId, $this->institution));
486
    }
487
488
    public function getAggregateRootId(): string
489
    {
490
        return $this->institutionConfigurationId;
491
    }
492
493
    /**
494
     * Check if role from institution is allowed to accredit roles
495
     *
496
     * @param Institution $institution
497
     * @return bool
498
     */
499
    public function isInstitutionAllowedToAccreditRoles(Institution $institution)
500
    {
501
        // This method is needed to support the situation pre FGA. In that situation the SelectRaaOptionChanged wasn't
502
        // fired and that would result in a situation were $this->selectRaaOption is null. If that occurs we should check
503
        // if the institution of the identity is the institution to validate.
504
        if ($this->selectRaaOption == null) {
505
            return $this->institution->equals($institution);
506
        }
507
508
        if ($this->selectRaaOption->hasInstitution($institution, $this->institution)) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return $this->selectRaaO...n, $this->institution);.
Loading history...
509
            return true;
510
        }
511
512
        return false;
513
    }
514
515
    protected function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
516
    {
517
        $this->institutionConfigurationId      = $event->institutionConfigurationId;
518
        $this->institution                     = $event->institution;
519
        $this->useRaLocationsOption            = $event->useRaLocationsOption;
520
        $this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
521
        $this->verifyEmailOption               = $event->verifyEmailOption;
522
        $this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
523
        $this->raLocations                     = new RaLocationList([]);
524
        $this->isMarkedAsDestroyed             = false;
525
    }
526
527
    /**
528
     * Apply the UseRaOptionChangedEvent
529
     *
530
     * To ensure the aggregate is correctly populated with the FGA options we ensure the UseRaOptionChangedEvent
531
     * can be applied on the aggregate. Refraining from doing this would result in the $this->useRaOption field only
532
     * being applied when applyNewInstitutionConfigurationCreatedEvent is called. And this might not be the case if
533
     * the fields where null'ed (removed from configuration).
534
     *
535
     * This also applies for applyUseRaaOptionChangedEvent & applySelectRaaOptionChangedEvent
536
     *
537
     * @param UseRaOptionChangedEvent $event
538
     */
539
    protected function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
540
    {
541
        $this->useRaOption = $event->useRaOption;
542
    }
543
544
    protected function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
545
    {
546
        $this->useRaaOption = $event->useRaaOption;
547
    }
548
549
    protected function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
550
    {
551
        $this->selectRaaOption = $event->selectRaaOption;
552
    }
553
554
    protected function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event)
555
    {
556
        $this->useRaLocationsOption = $event->useRaLocationsOption;
557
    }
558
559
    protected function applyShowRaaContactInformationOptionChangedEvent(
560
        ShowRaaContactInformationOptionChangedEvent $event
561
    ) {
562
        $this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
563
    }
564
565
    protected function applyVerifyEmailOptionChangedEvent(
566
        VerifyEmailOptionChangedEvent $event
567
    ) {
568
        $this->verifyEmailOption = $event->verifyEmailOption;
569
    }
570
571
    protected function applyNumberOfTokensPerIdentityOptionChangedEvent(
572
        NumberOfTokensPerIdentityOptionChangedEvent $event
573
    ) {
574
        $this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
575
    }
576
577
    protected function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event)
578
    {
579
        $this->allowedSecondFactorList = $event->allowedSecondFactorList;
580
    }
581
582
    protected function applyRaLocationAddedEvent(RaLocationAddedEvent $event)
583
    {
584
        $this->raLocations->add(
585
            RaLocation::create(
586
                $event->raLocationId,
587
                $event->raLocationName,
588
                $event->location,
589
                $event->contactInformation
590
            )
591
        );
592
    }
593
594
    protected function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event)
595
    {
596
        $raLocation = $this->raLocations->getById($event->raLocationId);
597
        $raLocation->rename($event->raLocationName);
598
    }
599
600
    protected function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event)
601
    {
602
        $raLocation = $this->raLocations->getById($event->raLocationId);
603
        $raLocation->relocate($event->location);
604
    }
605
606
    protected function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event)
607
    {
608
        $raLocation = $this->raLocations->getById($event->raLocationId);
609
        $raLocation->changeContactInformation($event->contactInformation);
610
    }
611
612
    protected function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event)
613
    {
614
        $this->raLocations->removeWithId($event->raLocationId);
615
    }
616
617
    /**
618
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
619
     * @param InstitutionConfigurationRemovedEvent $event
620
     */
621
    protected function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
622
    {
623
        // reset all configuration to defaults. This way, should it be rebuild, it seems like it is new again
624
        $this->raLocations                     = new RaLocationList([]);
625
        $this->useRaLocationsOption            = UseRaLocationsOption::getDefault();
626
        $this->showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
627
        $this->verifyEmailOption               = VerifyEmailOption::getDefault();
628
        $this->numberOfTokensPerIdentityOption = NumberOfTokensPerIdentityOption::getDefault();
629
        $this->allowedSecondFactorList         = AllowedSecondFactorList::blank();
630
        $this->useRaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa());
631
        $this->useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
632
        $this->selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
633
634
        $this->isMarkedAsDestroyed             = true;
635
    }
636
}
637