You are here

function field_collection_field_collection_from_field_get_children in Field collection 7

Get children callback.

1 call to field_collection_field_collection_from_field_get_children()
field_collection_field_collection_from_field_get_child in ctools/relationships/field_collection_from_field.inc
Get child callback.
1 string reference to 'field_collection_field_collection_from_field_get_children'
field_collection_from_field.inc in ctools/relationships/field_collection_from_field.inc
Plugin to provide a relationship handler for a field collection field.

File

ctools/relationships/field_collection_from_field.inc, line 30
Plugin to provide a relationship handler for a field collection field.

Code

function field_collection_field_collection_from_field_get_children($plugin, $parent) {
  $plugins = array();
  $instances_info = field_info_instances();
  if (isset($instances_info['field_collection_item'])) {
    $field_collection_items = $instances_info['field_collection_item'];
    foreach (field_read_instances() as $instance) {
      if (isset($field_collection_items[$instance['field_name']])) {
        $child_plugin_id = $parent . ':' . $instance['entity_type'] . ':' . $instance['bundle'] . ':' . $instance['field_name'];
        $child_plugin = $plugin;
        $child_plugin['context name'] = $instance['entity_type'] . ':' . $instance['bundle'] . ':' . $instance['field_name'];
        $child_plugin['title'] = t('!label field collection (!field_name) from !entity_type (!bundle)', array(
          '!label' => $instance['label'],
          '!field_name' => $instance['field_name'],
          '!entity_type' => $instance['entity_type'],
          '!bundle' => $instance['bundle'],
        ));
        $restrictions = array(
          'type' => array(
            $instance['bundle'],
          ),
        );
        $child_plugin['required context'] = new ctools_context_required(ucfirst($instance['entity_type']), $instance['entity_type'], $restrictions);
        $child_plugin['parent'] = $parent;
        $child_plugin['keyword'] = 'Field collection';
        $child_plugin['entity_type'] = $instance['entity_type'];
        $child_plugin['field_name'] = $instance['field_name'];
        $child_plugin['name'] = $child_plugin_id;
        $plugins[$child_plugin_id] = $child_plugin;
      }
    }
  }
  return $plugins;
}