You are here

function hook_entityconnect_ref_fields_alter in Entity connect 7.2

Same name and namespace in other branches
  1. 8.2 entityconnect.api.php \hook_entityconnect_ref_fields_alter()

hook_entityconnect_ref_fields_alter().

Allow modules to add fields as able to be connect. That will display the "add" and "edit" buttons.

Following example shows how to add buttons for bean entity.

Parameters

$ref_fields:

3 functions implement hook_entityconnect_ref_fields_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entityconnect_bean_entityconnect_ref_fields_alter in modules/entityconnect_bean/entityconnect_bean.module
Implements hook_entityconnect_get_ref_fields_alter().
entityconnect_eck_entityconnect_ref_fields_alter in modules/entityconnect_eck/entityconnect_eck.module
Implements hook_entityconnect_get_ref_fields_alter().
entityconnect_term_reference_entityconnect_ref_fields_alter in modules/entityconnect_term_reference/entityconnect_term_reference.module
Implements hook_entityconnect_get_ref_fields_alter().
1 invocation of hook_entityconnect_ref_fields_alter()
_entityconnect_get_ref_fields in includes/entityconnect.utils.inc
Helper function to retieve all allowed entityreference fields.

File

./entityconnect.api.php, line 35

Code

function hook_entityconnect_ref_fields_alter(&$ref_fields) {

  // We are parsing all fields.
  foreach (field_info_fields() as $id => $field) {

    // We want to be sure that bean fields are provided by entityreference module.
    if ($field['type'] == 'entityreference' && $field['module'] == 'entityreference') {
      $entity_reference_info = entityreference_get_selection_handler($field);
      $entity_type = $entity_reference_info->field['settings']['target_type'];

      // Check if the module is enabled.
      if (module_exists('bean_admin_ui')) {
        $entity_info = entity_get_info($entity_type);
        if (!empty($entity_info['module']) && $entity_info['module'] == 'bean') {

          // Check user access
          if (user_access('entityconnect add button') || user_access('entityconnect edit button')) {

            // Add field to the list.
            $ref_fields[$id] = $field;
          }
        }
      }
    }
  }
}