1010class ConfigHelper
1111{
1212 /**
13- * String with the location of this configuration.
14- * Used for error reporting.
13+ * @var \SimpleSAML\Configuration
1514 */
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 ;
5016
5117 /**
5218 * Constructor for this configuration parser.
@@ -56,19 +22,7 @@ class ConfigHelper
5622 */
5723 public function __construct (array $ config , string $ location )
5824 {
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 );
7226 }
7327
7428 /**
@@ -78,7 +32,7 @@ public function __construct(array $config, string $location)
7832 */
7933 public function getDebug (): bool
8034 {
81- return $ this ->debug ;
35+ return $ this ->config -> getOptionalBoolean ( ' debug ' , false ) ;
8236 }
8337
8438 /**
@@ -88,7 +42,7 @@ public function getDebug(): bool
8842 */
8943 public function getDrupalRoot (): string
9044 {
91- return $ this ->drupalRoot ;
45+ return $ this ->config -> getString ( ' drupalroot ' ) ;
9246 }
9347
9448 /**
@@ -98,7 +52,7 @@ public function getDrupalRoot(): string
9852 */
9953 public function getAttributes (): ?array
10054 {
101- return $ this ->attributes ;
55+ return $ this ->config -> getOptionalArray ( ' attributes ' , null ) ;
10256 }
10357
10458
@@ -109,7 +63,7 @@ public function getAttributes(): ?array
10963 */
11064 public function getDrupalLogoutUrl (): string
11165 {
112- return $ this ->drupalLogoutUrl ;
66+ return $ this ->config -> getString ( ' drupal_logout_url ' ) ;
11367 }
11468
11569 /**
@@ -119,6 +73,6 @@ public function getDrupalLogoutUrl(): string
11973 */
12074 public function getDrupalLoginUrl (): string
12175 {
122- return $ this ->drupalLoginUrl ;
76+ return $ this ->config -> getString ( ' drupal_login_url ' ) ;
12377 }
12478}
0 commit comments