You are here

protected function NameListFormatListBuilder::examples in Name Field 8

Provides some example based on names with various components set.

Parameters

\Drupal\name\Entity\NameListFormat $entity: The name format entity.

Return value

\Drupal\Component\Render\FormattableMarkup The example names with formatting applied.

1 call to NameListFormatListBuilder::examples()
NameListFormatListBuilder::buildRow in src/NameListFormatListBuilder.php
Builds a row for an entity in the entity listing.

File

src/NameListFormatListBuilder.php, line 143

Class

NameListFormatListBuilder
The name list builder.

Namespace

Drupal\name

Code

protected function examples(NameListFormat $entity) {
  $examples = [];
  foreach ([
    1,
    2,
    3,
    4,
  ] as $num) {
    $names = $this->generator
      ->generateSampleNames($num);
    $examples[] = $this
      ->t('(@num) %list', [
      '@num' => $num,
      '%list' => $this->formatter
        ->formatList($names, 'family', $entity
        ->id()),
    ]);
  }
  return new FormattableMarkup(implode('<br>', $examples), []);
}