uo__unit_formatter.inc 644 B

12345678910111213141516171819202122232425
  1. <?php
  2. class uo__unit_formatter extends ChadoFieldFormatter {
  3. // The default label for this field.
  4. public static $default_label = 'Unit';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = ['uo__unit'];
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. $content = '';
  12. if ($items[0]['value']) {
  13. $content = $items[0]['value'];
  14. }
  15. $element[0] = [
  16. // We create a render array to produce the desired markup,
  17. '#type' => 'markup',
  18. '#markup' => $content,
  19. ];
  20. }
  21. }