operation__analysis_formatter.inc 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class operation__analysis_formatter extends ChadoFieldFormatter {
  3. // The default label for this field.
  4. public static $default_label = 'Analysis';
  5. // The list of field types for which this formatter is appropriate.
  6. public static $field_types = ['operation__analysis'];
  7. /**
  8. * @see TripalFieldFormatter::view()
  9. */
  10. public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
  11. if (count($items) > 0) {
  12. $name_term = chado_get_semweb_term('analysis', 'name');
  13. $content = $items[0]['value'][$name_term];
  14. if (array_key_exists('entity', $items[0]['value'])) {
  15. list($entity_type, $entity_id) = explode(':', $items[0]['value']['entity']);
  16. $content = l($content, 'bio_data/' . $entity_id);
  17. }
  18. // The cardinality of this field is 1 so we don't have to
  19. // iterate through the items array, as there will never be more than 1.
  20. $element[0] = [
  21. '#type' => 'markup',
  22. '#markup' => $content,
  23. ];
  24. }
  25. }
  26. }