68 : Refinery\Transformation
69 {
72
73 return $this->
refinery->custom()->transformation(
static function (
$data) use (
74 $levels,
75 $intervals
78 return new Setup\NullConfig();
79 }
80
81 $protocol = 'http';
82 if (isset(
$data[
'https']) && is_array(
$data[
'https']) &&
$data[
'https'] !== []) {
83 $protocol = 'https';
84 }
85
86 $deletion_interval = false;
87 if (
88 isset(
$data[
'deletion_interval']) &&
89 is_array(
$data[
'deletion_interval']) &&
$data[
'deletion_interval'] !== []
90 ) {
91 $deletion_interval = true;
92 }
93
94 $ilias_proxy = false;
95 if (isset(
$data[
'ilias_proxy']) && is_array(
$data[
'ilias_proxy']) &&
$data[
'ilias_proxy'] !== []) {
96 $ilias_proxy = true;
97 }
98
99 $client_proxy = false;
100 if (isset(
$data[
'client_proxy']) && is_array(
$data[
'client_proxy']) &&
$data[
'client_proxy'] !== []) {
101 $client_proxy = true;
102 }
103
104 if (isset(
$data[
'address']) && !is_string(
$data[
'address'])) {
105 throw new InvalidArgumentException(sprintf(
106 '%s is not a valid value for address (must be a string). Please check your config file.',
108 ));
109 }
110
111 if (
112 isset(
$data[
'port']) && (
113 !is_numeric(
$data[
'port']) ||
114 ((
int)
$data[
'port'] < self::PORT_MIN || (
int)
$data[
'port'] > self::PORT_MAX)
115 )
116 ) {
117 throw new InvalidArgumentException(sprintf(
118 '%s is not a valid value for port (must be between %s and %s). Please check your config file.',
120 self::PORT_MIN,
121 self::PORT_MAX
122 ));
123 }
124
125 if (isset(
$data[
'sub_directory']) && !is_string(
$data[
'sub_directory'])) {
126 throw new InvalidArgumentException(sprintf(
127 '%s is not a valid value for sub_directory (must be a string). Please check your config file.',
128 $data[
'sub_directory'],
129 ));
130 }
131
132 if (isset(
$data[
'log']) && !is_string(
$data[
'log'])) {
133 throw new InvalidArgumentException(sprintf(
134 '%s is not a valid value for log (must be a string). Please check your config file.',
136 ));
137 }
138
139 if (isset(
$data[
'error_log']) && !is_string(
$data[
'error_log'])) {
140 throw new InvalidArgumentException(sprintf(
141 '%s is not a valid value for error_log (must be a string). Please check your config file.',
143 ));
144 }
145
146 if (
148 !in_array((
string) (
$data[
'log_level'] ??
''), $levels,
true)
149 ) {
150 throw new InvalidArgumentException(sprintf(
151 '%s is not a valid value for log_level (must be one of: %s). Please check your config file.',
152 $data[
'log_level'] ??
'',
153 implode(', ', $levels)
154 ));
155 }
156
157 if ($deletion_interval) {
158 if (!in_array(
$data[
'deletion_interval'][
'deletion_unit'] ??
null, $intervals,
true)) {
159 throw new InvalidArgumentException(sprintf(
160 '%s is not a valid value for deletion_unit (must be one of: %s). Please check your config file.',
161 $data[
'deletion_interval'][
'deletion_unit'] ??
'',
162 implode(', ', $intervals)
163 ));
164 }
165 if (
166 !isset(
$data[
'deletion_interval'][
'deletion_value']) ||
167 !is_numeric(
$data[
'deletion_interval'][
'deletion_value'])
168 ) {
169 throw new InvalidArgumentException(sprintf(
170 '%s is not a valid value for deletion_value. Please check your config file.',
171 $data[
'deletion_interval'][
'deletion_value'] ??
''
172 ));
173 }
174 if (
175 !isset(
$data[
'deletion_interval'][
'deletion_time']) ||
176 !is_string(
$data[
'deletion_interval'][
'deletion_time']) ||
177 !preg_match(
'/([01][0-9]|[2][0-3]):[0-5][0-9]/',
$data[
'deletion_interval'][
'deletion_time'])
178 ) {
179 throw new InvalidArgumentException(sprintf(
180 '%s is not a valid value for deletion_time. Please check your config file.',
181 $data[
'deletion_interval'][
'deletion_time'] ??
''
182 ));
183 }
184 }
185
187 $data[
'address'] ??
'',
188 (
int) (
$data[
'port'] ?? 0),
189 $data[
'sub_directory'] ??
'',
190 $protocol,
191 $data[
'https'][
'cert'] ??
'',
192 $data[
'https'][
'key'] ??
'',
193 $data[
'https'][
'dhparam'] ??
'',
195 $data[
'log_level'] ??
'',
196 $data[
'error_log'] ??
'',
197 $ilias_proxy,
198 $data[
'ilias_proxy'][
'ilias_url'] ??
'',
199 $client_proxy,
200 $data[
'client_proxy'][
'client_url'] ??
'',
201 $deletion_interval,
202 $data[
'deletion_interval'][
'deletion_unit'] ??
'',
203 (
int) (
$data[
'deletion_interval'][
'deletion_value'] ?? 0),
204 $data[
'deletion_interval'][
'deletion_time'] ??
''
205 );
206 });
207 }
A configuration for the setup.