function _tripal_get_bundle_field_element_details

3.x tripal.entities.api.inc _tripal_get_bundle_field_element_details($elements, &$field_details)

A recursive helper function for the tripal_get_bundle_details.

Parameters

$elementInfo:

Related topics

1 call to _tripal_get_bundle_field_element_details()
tripal_get_bundle_details in tripal/api/tripal.entities.api.inc
Retrieves details, including attached fields, for a given bundle.

File

tripal/api/tripal.entities.api.inc, line 1310
Provides an application programming interface (API) for working with TripalEntity content types (bundles) and their entities.

Code

function _tripal_get_bundle_field_element_details($elements, &$field_details) {
  $field_details['elements'] = array();
  foreach ($elements as $element_key => $element_info) {
    // Handle the entity element differnetly.
    if ($element_key == 'entity') {
      continue;
    }
    list($term_vocab, $term_accession) = explode(':', $element_key);
    $term = tripal_get_term_details($term_vocab, $term_accession);

    $element_details = array(
      'name' => $element_info['name'],
      'label' => array_key_exists('label', $element_info) ? $element_info['label'] : ucfirst(preg_replace('/_/', ' ', $term['name'])),
      'help' => array_key_exists('help', $element_info) ? $element_info['help'] : '',
      'term' => array(
        'accession' => $term_vocab . ':' . $term_accession,
        'name' => $term['name'],
        'definition' => $term['definition'],
        'url' => $term['url'],
      ),
      'required' => array_key_exists('required', $element_info) ? $element_info['required'] : FALSE,
      'type' => array_key_exists('type', $element_info) ? $element_info['type'] : 'xs:string',
      'readonly' => array_key_exists('readonly', $element_info) ? $element_info['readonly'] : TRUE,
    );
    if (array_key_exists('elements', $element_info) and is_array($element_info['elements'])) {
      _tripal_get_bundle_field_element_details($element_info['elements'], $element_details);
    }
    $field_details['elements'][] = $element_details;
  }
}