/** * Builds an individual term item for the term item list depending on the formatter. * * @param \Drupal\taxonomy\Entity\Term $term * @return string */ private function buildTermListItem(Term $term, $formatter) { if ($formatter === 'linked') { $link_url = Url::fromRoute('entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id())); return \Drupal::l($term->label(), $link_url); } return HTML::escape($term->label()); }