protected static function GoogleAnalyticsAdminSettingsForm::convertFormValueDataTypes in Google Analytics 8.2
Same name and namespace in other branches
- 8.3 src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::convertFormValueDataTypes()
- 4.x src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::convertFormValueDataTypes()
Prepare form data types for Json conversion.
Parameters
array $values: Array of values.
Return value
string Value with casted data type.
1 call to GoogleAnalyticsAdminSettingsForm::convertFormValueDataTypes()
- GoogleAnalyticsAdminSettingsForm::extractCreateFieldValues in src/
Form/ GoogleAnalyticsAdminSettingsForm.php - Extracts the values array from the element.
File
- src/
Form/ GoogleAnalyticsAdminSettingsForm.php, line 1036
Class
- GoogleAnalyticsAdminSettingsForm
- Configure Google_Analytics settings for this site.
Namespace
Drupal\google_analytics\FormCode
protected static function convertFormValueDataTypes(array $values) {
foreach ($values as $name => $value) {
// Convert data types.
$match = mb_strtolower($value);
if ($match == 'true') {
$value = TRUE;
}
elseif ($match == 'false') {
$value = FALSE;
}
// Convert other known fields.
switch ($name) {
case 'sampleRate':
// Float types.
settype($value, 'float');
break;
case 'siteSpeedSampleRate':
case 'cookieExpires':
// Integer types.
settype($value, 'integer');
break;
}
$values[$name] = $value;
}
return $values;
}