You are here

protected function NameFormatParser::renderFirstComponent in Name Field 8

Finds and renders the first renderable name component value.

This function does not by default sanitize the output unless the markup flag is set. If this is set, it runs the component through check_plain() and wraps the component in a span with the component name set as the class.

Parameters

array $values: An array of walues to find the first to render.

string $component_key: The component context.

string $modifier: Internal flag for processing.

Return value

string The rendered component.

1 call to NameFormatParser::renderFirstComponent()
NameFormatParser::generateTokens in src/NameFormatParser.php
Generates the tokens from the name item.

File

src/NameFormatParser.php, line 452

Class

NameFormatParser
Converts a name from an array of components into a defined format.

Namespace

Drupal\name

Code

protected function renderFirstComponent(array $values, $component_key, $modifier = NULL) {
  foreach ($values as $value) {
    $output = $this
      ->renderComponent($value, $component_key, $modifier);
    if (isset($output) && strlen($output)) {
      return $output;
    }
  }
  return NULL;
}