You are here

protected function HierarchicalTermFormatterTest::generateLinkString in Hierarchical Term Formatter 8

Generates a concatenated string of term links.

1 call to HierarchicalTermFormatterTest::generateLinkString()
HierarchicalTermFormatterTest::testFormatter in tests/src/Functional/HierarchicalTermFormatterTest.php
Tests Hierarchical Term Formatter core functionality.

File

tests/src/Functional/HierarchicalTermFormatterTest.php, line 61

Class

HierarchicalTermFormatterTest
Verifies Hierarchical Term Formatter.

Namespace

Drupal\Tests\hierarchical_term_formatter\Functional

Code

protected function generateLinkString(array $term_names, $separator) {
  $links = [];
  foreach ($term_names as $term_name) {
    $url = new Url('entity.taxonomy_term.canonical', [
      'taxonomy_term' => $this->createdTerms[$term_name],
    ]);
    $link = $this->container
      ->get('link_generator')
      ->generate($term_name, $url);
    $links[] = (string) $link;
  }
  return implode($separator, $links);
}