Skip to content

Commit 2628938

Browse files
committed
Minor refactoring for site settings for extra HTTP header
1 parent 05f8b77 commit 2628938

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

MeasurableSettings.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private function makeExtraHttpHeaderKeySetting()
199199
'Cookie' => Piwik::translate('PerformanceAudit_Settings_ExtraHttpHeaderKey_Cookie'),
200200
];
201201
$field->validate = function ($value) use ($self, $field) {
202-
if ($self->getSetting('has_extra_http_header')->getValue()) {
202+
if ($self->hasExtraHttpHeader()) {
203203
if (empty($value)) {
204204
throw new ValidatorException(Piwik::translate('General_ValidatorErrorEmptyValue'));
205205
}
@@ -227,7 +227,7 @@ private function makeExtraHttpHeaderValueSetting()
227227
$field->condition = 'is_enabled && has_extra_http_header';
228228
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
229229
$field->validate = function ($value) use ($self, $field) {
230-
if ($self->getSetting('has_extra_http_header')->getValue()) {
230+
if ($self->hasExtraHttpHeader()) {
231231
if (empty($value)) {
232232
throw new ValidatorException(Piwik::translate('General_ValidatorErrorEmptyValue'));
233233
}
@@ -288,4 +288,14 @@ public function hasGroupedUrls()
288288
{
289289
return $this->getSetting('has_grouped_urls')->getValue();
290290
}
291+
292+
/**
293+
* Returns if site has extra HTTP header for site.
294+
*
295+
* @return bool
296+
*/
297+
public function hasExtraHttpHeader()
298+
{
299+
return $this->getSetting('has_extra_http_header')->getValue();
300+
}
291301
}

Tasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private static function getLighthouse(int $idSite)
279279
if ($siteSettings->hasExtendedTimeout()) {
280280
self::$lighthouse[$idSite]->setTimeout(300);
281281
}
282-
if ($siteSettings->getSetting('has_extra_http_header')->getValue()) {
282+
if ($siteSettings->hasExtraHttpHeader()) {
283283
self::$lighthouse[$idSite]->setHeaders([
284284
$siteSettings->getSetting('extra_http_header_key')->getValue() => $siteSettings->getSetting('extra_http_header_value')->getValue()
285285
]);

0 commit comments

Comments
 (0)