You are here

function entityreference_prepopulate_crumbs_plugins in Crumbs, the Breadcrumbs suite 7.2

Same name and namespace in other branches
  1. 7 plugins/crumbs.entityreference_prepopulate.inc \entityreference_prepopulate_crumbs_plugins()

Implements hook_crumbs_plugins().

Parameters

crumbs_InjectedAPI_hookCrumbsPlugins $api:

File

plugins/crumbs.entityreference_prepopulate.inc, line 9

Code

function entityreference_prepopulate_crumbs_plugins($api) {
  foreach (field_info_fields() as $field_name => $field_info) {
    if (0 || $field_info['type'] !== 'entityreference' || empty($field_info['bundles']['node']) || empty($field_info['settings']['target_type'])) {
      continue;
    }
    $target_type = $field_info['settings']['target_type'];
    foreach ($field_info['bundles']['node'] as $node_type) {
      $instance = field_info_instance('node', $field_name, $node_type);
      if (0 || empty($instance['default_value_function']) || 'entityreference_prepopulate_field_default_value' !== $instance['default_value_function']) {
        continue;
      }
      $route = 'node/add/' . str_replace('_', '-', $node_type);
      $plugin = new entityreference_prepopulate_CrumbsMonoPlugin_node($node_type, $field_name, $target_type);
      $api
        ->routeMonoPlugin($route, "node.{$field_name}.{$node_type}", $plugin);
    }
  }
}