You are here

protected function GoogleAnalyticsAdminSettingsForm::getNameValueString in Google Analytics 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::getNameValueString()
  2. 4.x src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::getNameValueString()

Generates a string representation of an array.

This string format is suitable for edition in a textarea.

Parameters

array $values: An array of values, where array keys are values and array values are labels.

Return value

string The string representation of the $values array:

  • Values are separated by a carriage return.
  • Each value is in the format "name|value" or "value".
1 call to GoogleAnalyticsAdminSettingsForm::getNameValueString()
GoogleAnalyticsAdminSettingsForm::buildForm in src/Form/GoogleAnalyticsAdminSettingsForm.php
Form constructor.

File

src/Form/GoogleAnalyticsAdminSettingsForm.php, line 1014

Class

GoogleAnalyticsAdminSettingsForm
Configure Google_Analytics settings for this site.

Namespace

Drupal\google_analytics\Form

Code

protected function getNameValueString(array $values) {
  $lines = [];
  foreach ($values as $name => $value) {

    // Convert data types.
    if (is_bool($value)) {
      $value = $value ? 'true' : 'false';
    }
    $lines[] = "{$name}|{$value}";
  }
  return implode("\n", $lines);
}