function domain_entity_entity_field_instance in Domain Access Entity 7
Get the domain_entity field name and his settings for an entity type.
Return value
String The entity type.
4 calls to domain_entity_entity_field_instance()
- domain_entity_entity_presave in ./
domain_entity.module - Implements hook_entity_presave().
- domain_entity_query_alter in ./
domain_entity.module - Implements hook_query_alter().
- domain_entity_source_views_data_alter in domain_entity_source/
domain_entity_source.module - Implements hook_views_data_alter().
- domain_entity_views_data_alter in ./
domain_entity.module - Implements hook_views_data_alter().
File
- ./
domain_entity.module, line 330 - Defines field (e.g. domain_entity) for entities, and access query alter.
Code
function domain_entity_entity_field_instance($entity_type) {
// First check the static cache for a domain_entity field instances array.
$domain_entity_entity_field_instance =& drupal_static(__FUNCTION__);
// If it did not exist, init the array.
if (!isset($domain_entity_entity_field_instance)) {
$domain_entity_entity_field_instance = array();
}
// Look for an instance of this type, if it's not in the static cache.
if (!isset($domain_entity_entity_field_instance[$entity_type])) {
$domain_entity_field_instances = domain_entity_field_instances();
$query = "SELECT fci.field_name AS field_name, fci.data AS data FROM ";
$query .= "{field_config_instance} fci WHERE ";
$query .= "(fci.entity_type = :entity_type) AND ";
$query .= "(fci.field_name IN (:field_instance))";
$args = array(
':entity_type' => $entity_type,
':field_instance' => $domain_entity_field_instances,
);
$field_instance = db_query($query, $args)
->fetchAll();
if (isset($field_instance[0])) {
$domain_entity_entity_field_instance[$entity_type] = array(
'name' => $field_instance[0]->field_name,
'settings' => unserialize($field_instance[0]->data),
);
}
else {
return FALSE;
}
}
return $domain_entity_entity_field_instance[$entity_type];
}