public static function EntityHelper::getAllReferencesTo in Helper 7
File
- lib/
EntityHelper.php, line 467
Class
Code
public static function getAllReferencesTo($entity_type, array $entity_ids, EntityFieldQuery $query = NULL, $flatten = FALSE) {
if (!isset($query)) {
$query = new EntityFieldQuery();
$query
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
}
$references = array();
$fields = FieldHelper::getEntityReferencingFieldsByType($entity_type);
foreach ($fields as $field_name => $columns) {
foreach (array_keys($columns) as $column) {
$field_query = clone $query;
$field_query
->fieldCondition($field_name, $column, $entity_ids);
if ($results = $field_query
->execute()) {
if ($flatten) {
$references = drupal_array_merge_deep($references, $results);
}
else {
$references[$field_name . ':' . $column] = $results;
}
}
}
}
return $references;
}