You are here

public function ContainerTrait::cleanText in GoogleTagManager 8

Cleans a string representing a list of items.

Parameters

string $text: The string to clean.

string $format: The final format of $text, either 'string' or 'array'.

Return value

string The clean text.

1 call to ContainerTrait::cleanText()
ContainerTrait::validateFormValues in src/Form/ContainerTrait.php

File

src/Form/ContainerTrait.php, line 319

Class

ContainerTrait
Defines shared routines for the container and settings forms.

Namespace

Drupal\google_tag\Form

Code

public function cleanText($text, $format = 'string') {
  $text = explode("\n", $text);
  $text = array_map('trim', $text);
  $text = array_filter($text, 'trim');
  if ($format == 'string') {
    $text = implode("\n", $text);
  }
  return $text;
}