You are here

protected function NameListFormattableMarkup::escapeValues in Name Field 8

Escapes values if needed.

Parameters

array|string|\Drupal\Component\Render\MarkupInterface $value: A placeholder replacement value. Will recursively escape array values using the specified separator.

Return value

string The properly escaped replacement value.

2 calls to NameListFormattableMarkup::escapeValues()
NameListFormattableMarkup::__construct in src/Render/NameListFormattableMarkup.php
Constructor for NameListFormattableMarkup.
NameListFormattableMarkup::__toString in src/Render/NameListFormattableMarkup.php
Returns markup.

File

src/Render/NameListFormattableMarkup.php, line 62

Class

NameListFormattableMarkup
Formats a string for HTML display by replacing variable placeholders.

Namespace

Drupal\name\Render

Code

protected function escapeValues($value) {
  if (is_array($value)) {
    $escaped = [];
    foreach ($value as $child_value) {
      $escaped[] = $this
        ->escapeValues($child_value);
    }
    return implode($this->separator, $escaped);
  }
  return $value instanceof MarkupInterface ? (string) $value : Html::escape($value);
}