private function TripalContentService_v0_1::findField

3.x TripalContentService_v0_1.inc private TripalContentService_v0_1::findField($bundle, $expfield)

Find the field whose term matches the one provied.

2 calls to TripalContentService_v0_1::findField()
TripalContentService_v0_1::doEntityList in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a collection of resources for a given type.
TripalContentService_v0_1::doExpandedField in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resource for an expanded field of an entity.

File

tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc, line 151

Class

TripalContentService_v0_1

Code

private function findField($bundle, $expfield) {

  $value = array();
  $instances = field_info_instances('TripalEntity', $bundle->name);
  foreach ($instances as $instance) {
    $field_name = $instance['field_name'];
    $field = field_info_field($field_name);
    $field_type = $field['type'];
    // Skip fields of remote data.
    if ($field_type == 'remote__data') {
      continue;
    }
    $vocabulary = $instance['settings']['term_vocabulary'];
    $accession = $instance['settings']['term_accession'];
    $temp_term = tripal_get_term_details($vocabulary, $accession);
    // See if the name provided matches the field name after a bit of
    // cleanup.
    if (strtolower(preg_replace('/[^\w]/', '_', $temp_term['name'])) == strtolower($expfield)) {
      return array($field, $instance, $temp_term);
    }
    // Alternatively if the CV term accession matches then we're good too.
    if ($vocabulary . ':' . $accession == $expfield) {
      return array($field, $instance, $temp_term);
    }
  }
}