You are here

function _field_object_build_hierarchy in Corresponding Entity References 7.3

Helper function. Builds a FieldHierarchy object for the widget builder.

File

field_object/field_object.module, line 115

Code

function _field_object_build_hierarchy(array $field, array $instance, $entity_type, $entity) {
  $arguments = func_get_args();
  $hierarchy = new FieldHierarchy();

  // The instance should define a function which returns an array of FieldChain
  // objects to be added to the hierarchy.
  $function = $instance['settings']['function'];
  if ($function && is_callable($function)) {
    $chains = (array) call_user_func_array($function, $arguments);
    array_walk($chains, array(
      $hierarchy,
      'addChain',
    ));
  }
  return $hierarchy;
}