Plugin implementation of the 'taxonomy_term_reference_plain' formatter.
@FieldFormatter(
id = "taxonomy_term_reference_plain",
module = "taxonomy",
label = @Translation("Plain text"),
field_types = {
"taxonomy_term_reference"
}
)
Expanded class hierarchy of PlainFormatter
class PlainFormatter extends TaxonomyFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#markup' => check_plain($item['entity']
->label()),
);
}
return $elements;
}
}