sio__vocabulary_formatter.inc 702 B

123456789101112131415161718192021222324
  1. <?php
  2. class sio__vocabulary_formatter extends ChadoFieldFormatter {
  3. // The default lable for this field.
  4. public static $default_label = 'Vocabulary';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = ['sio__vocabulary'];
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. if (count($items) > 0) {
  12. // The cardinality of this field is 1 so we don't have to
  13. // iterate through the items array, as there will never be more than 1.
  14. $element[0] = [
  15. '#type' => 'markup',
  16. '#markup' => $items[0]['value'],
  17. ];
  18. }
  19. }
  20. }