-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurationUtility.php
More file actions
79 lines (66 loc) · 1.75 KB
/
ConfigurationUtility.php
File metadata and controls
79 lines (66 loc) · 1.75 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Fab\Formule\Utility;
/*
* This file is part of the Fab/Formule project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* A class for handling configuration of the extension
*/
class ConfigurationUtility implements SingletonInterface {
/**
* @var array
*/
protected $configuration = array();
/**
* Returns a class instance.
*
* @return \Fab\Formule\Utility\ConfigurationUtility|object
*/
static public function getInstance() {
return GeneralUtility::makeInstance(self::class);
}
/**
* Constructor
*/
public function __construct() {
$configuration = GeneralUtility::makeInstance(
ExtensionConfiguration::class
)->get('formule');
// Fill up configuration array with relevant values.
foreach ($configuration as $key => $value) {
$this->configuration[$key] = $value;
}
}
/**
* Returns a setting key.
*
* @param string $key
* @return mixed
*/
public function get(string $key) {
return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : NULL;
}
/**
* Set a setting key.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function set(string $key, $value): void {
$this->configuration[$key] = $value;
}
/**
* @return array
*/
public function getConfiguration(): array
{
return $this->configuration;
}
}