You are here

function field_entity_entity_query_alter in Field entity 7

Implements hook_entity_query_alter().

File

./field_entity.module, line 65
Field and Field Instance entity definitions.

Code

function field_entity_entity_query_alter($query) {
  $conditions =& $query->entityConditions;
  if (isset($conditions['entity_type']) && $conditions['entity_type']['value'] == 'field_instance_entity' && isset($conditions['bundle'])) {
    $entity_type_bundle = $conditions['bundle']['value'];
    if (is_array($entity_type_bundle)) {

      // Single bundle condition is supported only.
      // @todo Support multiple bundles.
      $entity_type_bundle = reset($entity_type_bundle);
      if ($entity_type_bundle) {
        list($entity_type, $bundle) = explode(':', $entity_type_bundle, 2);
        $query
          ->propertyCondition('entity_type', $entity_type, '=');
        $query
          ->propertyCondition('bundle', $bundle, '=');
      }
    }
    unset($conditions['bundle']);
  }
}