protected static function GoogleAnalyticsAdminSettingsForm::extractParameterValues in Google Analytics 4.x
Same name and namespace in other branches
- 8.3 src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::extractParameterValues()
Extracts the values array from the element.
Parameters
string $string: The raw string to extract values from.
Return value
array|null The array of extracted key/value pairs, or NULL if the string is invalid.
See also
\Drupal\options\Plugin\Field\FieldType\ListTextItem::allowedValuesString()
1 call to GoogleAnalyticsAdminSettingsForm::extractParameterValues()
- GoogleAnalyticsAdminSettingsForm::validateParameterValues in src/
Form/ GoogleAnalyticsAdminSettingsForm.php - The #element_validate callback for parameters.
File
- src/
Form/ GoogleAnalyticsAdminSettingsForm.php, line 984
Class
- GoogleAnalyticsAdminSettingsForm
- Configure Google_Analytics settings for this site.
Namespace
Drupal\google_analytics\FormCode
protected static function extractParameterValues($string) {
$values = [];
$list = explode("\n", $string);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
foreach ($list as $text) {
// Check for an explicit key.
$matches = [];
if (preg_match('/(.*)\\|(.*)/', $text, $matches)) {
// Trim key and value to avoid unwanted spaces issues.
$name = trim($matches[1]);
$value = trim($matches[2]);
}
else {
return NULL;
}
$values[$name] = $value;
}
return self::convertFormValueDataTypes($values);
}