entity_get_info($entity_type = NULL)Get the entity info array of an entity type.
@see hook_entity_info_alter()
$entity_type The entity type, e.g. node, for which the info shall be returned, or NULL to return an array with info about all types.
includes/common.inc, line 6229
<?php
function entity_get_info($entity_type = NULL) {
global $language;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['entity_info'] = &drupal_static(__FUNCTION__);
}
$entity_info = &$drupal_static_fast['entity_info'];
// hook_entity_info() includes translated strings, so each language is cached
// separately.
$langcode = $language->language;
if (empty($entity_info)) {
if ($cache = cache_get("entity_info:$langcode")) {
$entity_info = $cache->data;
}
else {
$entity_info = module_invoke_all('entity_info');
// Merge in default values.
foreach ($entity_info as $name => $data) {
$entity_info[$name] += array(
'fieldable' => FALSE,
'controller class' => 'DrupalDefaultEntityController',
'static cache' => TRUE,
'load hook' => $name . '_load',
'bundles' => array(),
'view modes' => array(),
'object keys' => array(),
'cacheable' => TRUE,
'translation' => array(),
);
$entity_info[$name]['object keys'] += array(
'revision' => '',
'bundle' => '',
);
// If no bundle key is provided, assume a single bundle, named after
// the entity type.
if (empty($entity_info[$name]['object keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
$entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
}
}
// Let other modules alter the entity info.
drupal_alter('entity_info', $entity_info);
cache_set("entity_info:$langcode", $entity_info);
}
}
if (empty($entity_type)) {
return $entity_info;
}
elseif (isset($entity_info[$entity_type])) {
return $entity_info[$entity_type];
}
}
?>