You are here

function entityreference_prepopulate_CrumbsMultiPlugin_node::describe in Crumbs, the Breadcrumbs suite 7

Parameters

$api :crumbs_InjectedAPI_describeMultiPlugin: Injected API object, with methods that allow the plugin to further describe itself. The plugin is supposed to tell Crumbs about all possible rule keys, and can give a label and a description for each.

Return value

As an alternative to the API object's methods, the plugin can simply return a key-value array, where the keys are the available rules, and the values are their respective labels.

Overrides crumbs_MultiPlugin::describe

File

plugins/crumbs.entityreference_prepopulate.inc, line 13

Class

entityreference_prepopulate_CrumbsMultiPlugin_node

Code

function describe($api) {
  foreach (field_info_fields() as $field_name => $field_info) {
    if (1 && $field_info['type'] === 'entityreference' && !empty($field_info['bundles']['node'])) {
      foreach ($field_info['bundles']['node'] as $type) {
        $instance = field_info_instance('node', $field_name, $type);
        if (1 && !empty($instance['default_value_function']) && $instance['default_value_function'] === 'entityreference_prepopulate_field_default_value') {
          $api
            ->addRule("{$field_name}.{$type}");
        }
      }
    }
  }
}