You are here

function _entity_bundle_plugin_check_incompatible_fields in Entity bundle plugin 7

Utility function: check that a set of fields are compatible with each other.

1 call to _entity_bundle_plugin_check_incompatible_fields()
entity_bundle_plugin_rebuild_fields in ./entity_bundle_plugin.module
Rebuild the fields for a given entity type.

File

./entity_bundle_plugin.module, line 141
EntityBundlePlugin module.

Code

function _entity_bundle_plugin_check_incompatible_fields($field_name, $field_definitions) {
  if (count($field_definitions) > 1) {
    $groups = array();
    $group_values = array();
    foreach ($field_definitions as $plugin_name => $field_plugin) {
      $found_group = NULL;
      foreach ($group_values as $group_id => $group_value) {
        if ($field_plugin == $group_value) {
          $found_group = $group_id;
          break;
        }
      }
      if (isset($found_group)) {
        $groups[$found_group][] = $plugin_name;
      }
      else {
        $groups[] = array(
          $plugin_name,
        );
        $group_values[] = $field_plugin;
      }
    }
    if (count($groups) > 1) {
      $displayed_groups = array();
      foreach ($groups as $group) {
        $displayed_groups[] = '(' . implode(', ', $group) . ')';
      }
      throw new Exception(t('@field_name is incompatible between @groups', array(
        '@field_name' => $field_name,
        '@groups' => implode(', ', $displayed_groups),
      )));
    }
  }
  return FALSE;
}