-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathFormFactory.php
More file actions
55 lines (48 loc) · 1.49 KB
/
FormFactory.php
File metadata and controls
55 lines (48 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
/*
* This file is part of the simplesamlphp-module-oidc.
*
* Copyright (C) 2018 by the Spanish Research and Academic Network.
*
* This code was developed by Universidad de Córdoba (UCO https://www.uco.es)
* for the RedIRIS SIR service (SIR: http://www.rediris.es/sir)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SimpleSAML\Module\oidc\Factories;
use Nette\Forms\Form;
use SimpleSAML\Error\Exception;
use SimpleSAML\Module\oidc\Bridges\SspBridge;
use SimpleSAML\Module\oidc\Forms\Controls\CsrfProtection;
use SimpleSAML\Module\oidc\Helpers;
use SimpleSAML\Module\oidc\ModuleConfig;
class FormFactory
{
public function __construct(
protected readonly ModuleConfig $moduleConfig,
protected readonly CsrfProtection $csrfProtection,
protected readonly SspBridge $sspBridge,
protected readonly Helpers $helpers,
) {
}
/**
* @param class-string $classname Form classname
*
* @throws \SimpleSAML\Error\Exception
*/
public function build(string $classname): Form
{
if (!is_a($classname, Form::class, true)) {
throw new Exception("Invalid form: $classname");
}
/** @psalm-suppress UnsafeInstantiation */
return new $classname(
$this->moduleConfig,
$this->csrfProtection,
$this->sspBridge,
$this->helpers,
);
}
}