You are here

function nodereference_count_get_counted_nodereference_fields in Nodereference Count 7

From a set of node reference fields get those that are counted by a nodereference count field.

Parameters

$node_references: An array of node reference fields.

Return value

An array of field names.

1 call to nodereference_count_get_counted_nodereference_fields()
nodereference_count_references_update in ./nodereference_count.module
Identify counted node references on a node and trigger an update of the referenced nodes.

File

./nodereference_count.module, line 295
Defines a field type for counting the references to a node.

Code

function nodereference_count_get_counted_nodereference_fields($node_references) {
  $counted_fields = array();
  $bundles = field_info_instances('node');
  foreach ($bundles as $bundle) {
    foreach ($bundle as $instance) {
      if (isset($instance['settings']['counted_reference_fields'])) {
        foreach ($node_references as $node_reference) {
          if (in_array($node_reference['field_name'], $instance['settings']['counted_reference_fields'], TRUE)) {
            $counted_fields[$node_reference['field_name']] = $node_reference['field_name'];
          }
        }
      }
    }
  }
  return $counted_fields;
}