commit 2f04d29c1b2a85962db0066fc01067e313ade1e6
Author: Damien Tournoud <damien@commerceguys.com>
Date:   Fri Feb 3 11:13:46 2012 +0100

    Feature #1427038: Allow behaviors to alter the views data definition.

diff --git a/plugins/behavior/abstract.inc b/plugins/behavior/abstract.inc
index 90a1daf..065d261 100644
--- a/plugins/behavior/abstract.inc
+++ b/plugins/behavior/abstract.inc
@@ -23,6 +23,13 @@ interface EntityReference_BehaviorHandler {
   public function property_info_alter(&$info, $entity_type, $field, $instance, $field_type);
 
   /**
+   * Alter the views data of a field.
+   *
+   * @see entityreference_field_views_data()
+   */
+  public function views_data_alter(&$data, $field);
+
+  /**
    * Act on loading entity reference fields of entities.
    *
    * @see hook_field_load()
@@ -103,6 +110,8 @@ abstract class EntityReference_BehaviorHandler_Abstract implements EntityReferen
 
   public function property_info_alter(&$info, $entity_type, $field, $instance, $field_type) {}
 
+  public function views_data_alter(&$data, $field) {}
+
   public function load($entity_type, $entities, $field, $instances, $langcode, &$items) {}
 
   public function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {}
diff --git a/views/entityreference.views.inc b/views/entityreference.views.inc
index 76cbc2b..1e15bf4 100644
--- a/views/entityreference.views.inc
+++ b/views/entityreference.views.inc
@@ -32,6 +32,11 @@ function entityreference_field_views_data($field) {
     }
   }
 
+  // Invoke the behaviors to allow them to change the properties.
+  foreach (entityreference_get_behavior_handlers($field) as $handler) {
+    $handler->views_data_alter($data, $field);
+  }
+
   return $data;
 }
 
