Completed
Pull Request — develop (#320)
by Michiel
04:42
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\InstitutionAuthorizationOption;
44
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
45
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
46
use Surfnet\Stepup\Configuration\Value\Location;
47
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
48
use Surfnet\Stepup\Configuration\Value\RaLocationId;
49
use Surfnet\Stepup\Configuration\Value\RaLocationList;
50
use Surfnet\Stepup\Configuration\Value\RaLocationName;
51
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
52
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
53
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
54
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
55
use Surfnet\Stepup\Exception\DomainException;
56
57
/**
58
 * InstitutionConfiguration aggregate root
59
 *
60
 * Some things to know about this aggregate:
61
 *
62
 * 1. The aggregate is instantiated by InstitutionConfigurationCommandHandler by calling the
63
 *    handleReconfigureInstitutionConfigurationOptionsCommand method. It does so, not by using the projections to build
64
 *    the aggregate but by playing the events onto the aggregate.
65
 * 2. If one of the configuration options should be nullable, take a look at the applyUseRaOptionChangedEvent doc block
66
 *
67
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects) Events and value objects
68
 * @SuppressWarnings(PHPMD.TooManyMethods) AggregateRoot
69
 * @SuppressWarnings(PHPMD.TooManyPublicMethods) AggregateRoot
70
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) AggregateRoot
71
 */
72
class InstitutionConfiguration extends EventSourcedAggregateRoot implements InstitutionConfigurationInterface
73
{
74
    /**
75
     * @var InstitutionConfigurationId
76
     */
77
    private $institutionConfigurationId;
78
79
    /**
80
     * @var Institution
81
     */
82
    private $institution;
83
84
    /**
85
     * @var RaLocationList
86
     */
87
    private $raLocations;
88
89
    /**
90
     * @var UseRaLocationsOption
91
     */
92
    private $useRaLocationsOption;
93
94
    /**
95
     * @var ShowRaaContactInformationOption
96
     */
97
    private $showRaaContactInformationOption;
98
99
    /**
100
     * @var VerifyEmailOption
101
     */
102
    private $verifyEmailOption;
103
104
    /**
105
     * @var NumberOfTokensPerIdentityOption
106
     */
107
    private $numberOfTokensPerIdentityOption;
108
109
    /**
110
     * @var SelfVetOption
111
     */
112
    private $selfVetOption;
113
114
    /**
115
     * @var InstitutionAuthorizationOption
116
     */
117
    private $useRaOption;
118
119
    /**
120
     * @var InstitutionAuthorizationOption
121
     */
122
123
    private $useRaaOption;
124
125
    /**
126
     * @var InstitutionAuthorizationOption
127
     */
128
    private $selectRaaOption;
129
130
    /**
131
     * @var AllowedSecondFactorList
132
     */
133
    private $allowedSecondFactorList;
134
135
    /**
136
     * @var boolean
137
     */
138
    private $isMarkedAsDestroyed;
139
140
    /**
141
     * @param InstitutionConfigurationId $institutionConfigurationId
142
     * @param Institution $institution
143
     * @return InstitutionConfiguration
144
     */
145
    public static function create(InstitutionConfigurationId $institutionConfigurationId, Institution $institution)
146
    {
147
        $institutionConfiguration = new self;
148
        $institutionConfiguration->apply(
149
            new NewInstitutionConfigurationCreatedEvent(
150
                $institutionConfigurationId,
151
                $institution,
152
                UseRaLocationsOption::getDefault(),
153
                ShowRaaContactInformationOption::getDefault(),
154
                VerifyEmailOption::getDefault(),
155
                NumberOfTokensPerIdentityOption::getDefault(),
156
                SelfVetOption::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(
201
                $this->institutionConfigurationId,
202
                $this->institution,
203
                UseRaLocationsOption::getDefault(),
204
                ShowRaaContactInformationOption::getDefault(),
205
                VerifyEmailOption::getDefault(),
206
                NumberOfTokensPerIdentityOption::getDefault(),
207
                SelfVetOption::getDefault()
208
            )
209
        );
210
        $this->apply(new AllowedSecondFactorListUpdatedEvent(
211
            $this->institutionConfigurationId,
212
            $this->institution,
213
            AllowedSecondFactorList::blank()
214
        ));
215
        $this->apply(
216
            new UseRaOptionChangedEvent(
217
                $this->institutionConfigurationId,
218
                $this->institution,
219
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
220
            )
221
        );
222
        $this->apply(
223
            new UseRaaOptionChangedEvent(
224
                $this->institutionConfigurationId,
225
                $this->institution,
226
                InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
227
            )
228
        );
229
        $this->apply(
230
            new SelectRaaOptionChangedEvent(
231
                $this->institutionConfigurationId,
232
                $this->institution,
233
                InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
234
            )
235
        );
236
237
        return $this;
238
    }
239
240
    final public function __construct()
241
    {
242
    }
243
244
    public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption)
245
    {
246
        if ($this->useRaLocationsOption->equals($useRaLocationsOption)) {
247
            return;
248
        }
249
250
        $this->apply(
251
            new UseRaLocationsOptionChangedEvent(
252
                $this->institutionConfigurationId,
253
                $this->institution,
254
                $useRaLocationsOption
255
            )
256
        );
257
    }
258
259
    public function configureShowRaaContactInformationOption(ShowRaaContactInformationOption $showRaaContactInformationOption)
260
    {
261
        if ($this->showRaaContactInformationOption->equals($showRaaContactInformationOption)) {
262
            return;
263
        }
264
265
        $this->apply(
266
            new ShowRaaContactInformationOptionChangedEvent(
267
                $this->institutionConfigurationId,
268
                $this->institution,
269
                $showRaaContactInformationOption
270
            )
271
        );
272
    }
273
274
    public function configureVerifyEmailOption(VerifyEmailOption $verifyEmailOption)
275
    {
276
        if ($this->verifyEmailOption->equals($verifyEmailOption)) {
277
            return;
278
        }
279
280
        $this->apply(
281
            new VerifyEmailOptionChangedEvent(
282
                $this->institutionConfigurationId,
283
                $this->institution,
284
                $verifyEmailOption
285
            )
286
        );
287
    }
288
289
    public function configureNumberOfTokensPerIdentityOption(
290
        NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption
291
    ) {
292
        if ($this->numberOfTokensPerIdentityOption->equals($numberOfTokensPerIdentityOption)) {
293
            return;
294
        }
295
296
        $this->apply(
297
            new NumberOfTokensPerIdentityOptionChangedEvent(
298
                $this->institutionConfigurationId,
299
                $this->institution,
300
                $numberOfTokensPerIdentityOption
301
            )
302
        );
303
    }
304
305
    public function configureSelfVetOption(SelfVetOption $selfVetOption)
306
    {
307
        if ($this->selfVetOption->equals($selfVetOption)) {
308
            return;
309
        }
310
311
        $this->apply(
312
            new SelfVetOptionChangedEvent(
313
                $this->institutionConfigurationId,
314
                $this->institution,
315
                $selfVetOption
316
            )
317
        );
318
    }
319
320 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...
321
    {
322
        if ($this->useRaOption !== null
323
            && $this->useRaOption->equals($useRaOption)
324
        ) {
325
            return;
326
        }
327
328
        $this->apply(
329
            new UseRaOptionChangedEvent(
330
                $this->institutionConfigurationId,
331
                $this->institution,
332
                $useRaOption
333
            )
334
        );
335
    }
336
337 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...
338
    {
339
        if ($this->useRaaOption !== null
340
            && $this->useRaaOption->equals($useRaaOption)
341
        ) {
342
            return;
343
        }
344
345
        $this->apply(
346
            new UseRaaOptionChangedEvent(
347
                $this->institutionConfigurationId,
348
                $this->institution,
349
                $useRaaOption
350
            )
351
        );
352
    }
353
354 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...
355
    {
356
        if ($this->selectRaaOption !== null
357
            && $this->selectRaaOption->equals($selectRaaOption)
358
        ) {
359
            return;
360
        }
361
362
        $this->apply(
363
            new SelectRaaOptionChangedEvent(
364
                $this->institutionConfigurationId,
365
                $this->institution,
366
                $selectRaaOption
367
            )
368
        );
369
    }
370
371
    public function updateAllowedSecondFactorList(AllowedSecondFactorList $allowedSecondFactorList)
372
    {
373
        // AllowedSecondFactorList can be null for InstitutionConfigurations for which this functionality did not exist
374
        if ($this->allowedSecondFactorList !== null
375
            && $this->allowedSecondFactorList->equals($allowedSecondFactorList)
376
        ) {
377
            return;
378
        }
379
380
        $this->apply(
381
            new AllowedSecondFactorListUpdatedEvent(
382
                $this->institutionConfigurationId,
383
                $this->institution,
384
                $allowedSecondFactorList
385
            )
386
        );
387
    }
388
389
    /**
390
     * @param RaLocationId $raLocationId
391
     * @param RaLocationName $raLocationName
392
     * @param Location $location
393
     * @param ContactInformation $contactInformation
394
     */
395
    public function addRaLocation(
396
        RaLocationId $raLocationId,
397
        RaLocationName $raLocationName,
398
        Location $location,
399
        ContactInformation $contactInformation
400
    ) {
401 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...
402
            throw new DomainException(sprintf(
403
                'Cannot add RaLocation with RaLocationId "%s" to RaLocations of InstitutionConfiguration "%s":'
404
                . ' it is already present',
405
                $raLocationId,
406
                $this->getAggregateRootId()
407
            ));
408
        }
409
410
        $this->apply(new RaLocationAddedEvent(
411
            $this->institutionConfigurationId,
412
            $this->institution,
413
            $raLocationId,
414
            $raLocationName,
415
            $location,
416
            $contactInformation
417
        ));
418
    }
419
420
    /**
421
     * @param RaLocationId $raLocationId
422
     * @param RaLocationName $raLocationName
423
     * @param Location $location
424
     * @param ContactInformation $contactInformation
425
     */
426
    public function changeRaLocation(
427
        RaLocationId $raLocationId,
428
        RaLocationName $raLocationName,
429
        Location $location,
430
        ContactInformation $contactInformation
431
    ) {
432 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...
433
            throw new DomainException(sprintf(
434
                'Cannot change RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
435
                . ' it is not present',
436
                $raLocationId,
437
                $this->getAggregateRootId()
438
            ));
439
        }
440
441
        $raLocation = $this->raLocations->getById($raLocationId);
442
443
        if (!$raLocation->getName()->equals($raLocationName)) {
444
            $this->apply(
445
                new RaLocationRenamedEvent($this->institutionConfigurationId, $raLocationId, $raLocationName)
446
            );
447
        }
448
        if (!$raLocation->getLocation()->equals($location)) {
449
            $this->apply(
450
                new RaLocationRelocatedEvent($this->institutionConfigurationId, $raLocationId, $location)
451
            );
452
        }
453
        if (!$raLocation->getContactInformation()->equals($contactInformation)) {
454
            $this->apply(
455
                new RaLocationContactInformationChangedEvent(
456
                    $this->institutionConfigurationId,
457
                    $raLocationId,
458
                    $contactInformation
459
                )
460
            );
461
        }
462
    }
463
464
    /**
465
     * @param RaLocationId $raLocationId
466
     */
467
    public function removeRaLocation(RaLocationId $raLocationId)
468
    {
469 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...
470
            throw new DomainException(sprintf(
471
                'Cannot remove RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
472
                . ' it is not present',
473
                $raLocationId,
474
                $this->getAggregateRootId()
475
            ));
476
        }
477
478
        $this->apply(new RaLocationRemovedEvent($this->institutionConfigurationId, $raLocationId));
479
    }
480
481
    /**
482
     * @return void
483
     */
484
    public function destroy()
485
    {
486
        $this->apply(new InstitutionConfigurationRemovedEvent($this->institutionConfigurationId, $this->institution));
487
    }
488
489
    public function getAggregateRootId(): string
490
    {
491
        return $this->institutionConfigurationId;
492
    }
493
494
    /**
495
     * Check if role from institution is allowed to accredit roles
496
     *
497
     * @param Institution $institution
498
     * @return bool
499
     */
500
    public function isInstitutionAllowedToAccreditRoles(Institution $institution)
501
    {
502
        // This method is needed to support the situation pre FGA. In that situation the SelectRaaOptionChanged wasn't
503
        // fired and that would result in a situation were $this->selectRaaOption is null. If that occurs we should check
504
        // if the institution of the identity is the institution to validate.
505
        if ($this->selectRaaOption == null) {
506
            return $this->institution->equals($institution);
507
        }
508
509
        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...
510
            return true;
511
        }
512
513
        return false;
514
    }
515
516
    protected function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
517
    {
518
        $this->institutionConfigurationId      = $event->institutionConfigurationId;
519
        $this->institution                     = $event->institution;
520
        $this->useRaLocationsOption            = $event->useRaLocationsOption;
521
        $this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
522
        $this->verifyEmailOption               = $event->verifyEmailOption;
523
        $this->selfVetOption = $event->selfVetOption;
524
        $this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
525
        $this->raLocations                     = new RaLocationList([]);
526
        $this->isMarkedAsDestroyed             = false;
527
    }
528
529
    /**
530
     * Apply the UseRaOptionChangedEvent
531
     *
532
     * To ensure the aggregate is correctly populated with the FGA options we ensure the UseRaOptionChangedEvent
533
     * can be applied on the aggregate. Refraining from doing this would result in the $this->useRaOption field only
534
     * being applied when applyNewInstitutionConfigurationCreatedEvent is called. And this might not be the case if
535
     * the fields where null'ed (removed from configuration).
536
     *
537
     * This also applies for applyUseRaaOptionChangedEvent & applySelectRaaOptionChangedEvent
538
     *
539
     * @param UseRaOptionChangedEvent $event
540
     */
541
    protected function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
542
    {
543
        $this->useRaOption = $event->useRaOption;
544
    }
545
546
    protected function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
547
    {
548
        $this->useRaaOption = $event->useRaaOption;
549
    }
550
551
    protected function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
552
    {
553
        $this->selectRaaOption = $event->selectRaaOption;
554
    }
555
556
    protected function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event)
557
    {
558
        $this->useRaLocationsOption = $event->useRaLocationsOption;
559
    }
560
561
    protected function applyShowRaaContactInformationOptionChangedEvent(
562
        ShowRaaContactInformationOptionChangedEvent $event
563
    ) {
564
        $this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
565
    }
566
567
    protected function applyVerifyEmailOptionChangedEvent(
568
        VerifyEmailOptionChangedEvent $event
569
    ) {
570
        $this->verifyEmailOption = $event->verifyEmailOption;
571
    }
572
573
    protected function applySelfVetOptionChangedEvent(
574
        SelfVetOptionChangedEvent $event
575
    ) {
576
        $this->selfVetOption = $event->selfVetOption;
577
    }
578
579
    protected function applyNumberOfTokensPerIdentityOptionChangedEvent(
580
        NumberOfTokensPerIdentityOptionChangedEvent $event
581
    ) {
582
        $this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
583
    }
584
585
    protected function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event)
586
    {
587
        $this->allowedSecondFactorList = $event->allowedSecondFactorList;
588
    }
589
590
    protected function applyRaLocationAddedEvent(RaLocationAddedEvent $event)
591
    {
592
        $this->raLocations->add(
593
            RaLocation::create(
594
                $event->raLocationId,
595
                $event->raLocationName,
596
                $event->location,
597
                $event->contactInformation
598
            )
599
        );
600
    }
601
602
    protected function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event)
603
    {
604
        $raLocation = $this->raLocations->getById($event->raLocationId);
605
        $raLocation->rename($event->raLocationName);
606
    }
607
608
    protected function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event)
609
    {
610
        $raLocation = $this->raLocations->getById($event->raLocationId);
611
        $raLocation->relocate($event->location);
612
    }
613
614
    protected function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event)
615
    {
616
        $raLocation = $this->raLocations->getById($event->raLocationId);
617
        $raLocation->changeContactInformation($event->contactInformation);
618
    }
619
620
    protected function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event)
621
    {
622
        $this->raLocations->removeWithId($event->raLocationId);
623
    }
624
625
    /**
626
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
627
     * @param InstitutionConfigurationRemovedEvent $event
628
     */
629
    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...
630
    {
631
        // reset all configuration to defaults. This way, should it be rebuild, it seems like it is new again
632
        $this->raLocations                     = new RaLocationList([]);
633
        $this->useRaLocationsOption            = UseRaLocationsOption::getDefault();
634
        $this->showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
635
        $this->verifyEmailOption               = VerifyEmailOption::getDefault();
636
        $this->numberOfTokensPerIdentityOption = NumberOfTokensPerIdentityOption::getDefault();
637
        $this->allowedSecondFactorList         = AllowedSecondFactorList::blank();
638
        $this->useRaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa());
639
        $this->useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
640
        $this->selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
641
642
        $this->isMarkedAsDestroyed             = true;
643
    }
644
}
645