10
10
class ConfigHelper
11
11
{
12
12
/**
13
- * String with the location of this configuration.
14
- * Used for error reporting.
13
+ * @var \SimpleSAML\Configuration
15
14
*/
16
- private string $ location ;
17
-
18
-
19
- /**
20
- * The filesystem path to the Drupal directory
21
- */
22
- private string $ drupalRoot ;
23
-
24
-
25
- /**
26
- * Whether debug output is enabled.
27
- *
28
- * @var bool
29
- */
30
- private bool $ debug ;
31
-
32
-
33
- /**
34
- * The attributes we should fetch. Can be NULL in which case we will fetch all attributes.
35
- */
36
- private ?array $ attributes ;
37
-
38
-
39
- /**
40
- * The Drupal logout URL
41
- */
42
- private string $ drupalLogoutUrl ;
43
-
44
-
45
- /**
46
- * The Drupal login URL
47
- */
48
- private string $ drupalLoginUrl ;
49
-
15
+ private Configuration $ config ;
50
16
51
17
/**
52
18
* Constructor for this configuration parser.
@@ -56,19 +22,7 @@ class ConfigHelper
56
22
*/
57
23
public function __construct (array $ config , string $ location )
58
24
{
59
- assert (is_array ($ config ));
60
- assert (is_string ($ location ));
61
-
62
- $ this ->location = $ location ;
63
-
64
- /* Get authsource configuration. */
65
- $ config = Configuration::loadFromArray ($ config , $ location );
66
-
67
- $ this ->drupalRoot = $ config ->getString ('drupalroot ' );
68
- $ this ->debug = $ config ->getOptionalBoolean ('debug ' , false );
69
- $ this ->attributes = $ config ->getOptionalArray ('attributes ' , null );
70
- $ this ->drupalLogoutUrl = $ config ->getString ('drupal_logout_url ' );
71
- $ this ->drupalLoginUrl = $ config ->getString ('drupal_login_url ' );
25
+ $ this ->config = Configuration::loadFromArray ($ config , $ location );
72
26
}
73
27
74
28
/**
@@ -78,7 +32,7 @@ public function __construct(array $config, string $location)
78
32
*/
79
33
public function getDebug (): bool
80
34
{
81
- return $ this ->debug ;
35
+ return $ this ->config -> getOptionalBoolean ( ' debug ' , false ) ;
82
36
}
83
37
84
38
/**
@@ -88,7 +42,7 @@ public function getDebug(): bool
88
42
*/
89
43
public function getDrupalRoot (): string
90
44
{
91
- return $ this ->drupalRoot ;
45
+ return $ this ->config -> getString ( ' drupalroot ' ) ;
92
46
}
93
47
94
48
/**
@@ -98,7 +52,7 @@ public function getDrupalRoot(): string
98
52
*/
99
53
public function getAttributes (): ?array
100
54
{
101
- return $ this ->attributes ;
55
+ return $ this ->config -> getOptionalArray ( ' attributes ' , null ) ;
102
56
}
103
57
104
58
@@ -109,7 +63,7 @@ public function getAttributes(): ?array
109
63
*/
110
64
public function getDrupalLogoutUrl (): string
111
65
{
112
- return $ this ->drupalLogoutUrl ;
66
+ return $ this ->config -> getString ( ' drupal_logout_url ' ) ;
113
67
}
114
68
115
69
/**
@@ -119,6 +73,6 @@ public function getDrupalLogoutUrl(): string
119
73
*/
120
74
public function getDrupalLoginUrl (): string
121
75
{
122
- return $ this ->drupalLoginUrl ;
76
+ return $ this ->config -> getString ( ' drupal_login_url ' ) ;
123
77
}
124
78
}
0 commit comments