7.x common.inc entity_get_info($entity_type = NULL)

Get the entity info array of an entity type.


$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.

See also



35 calls to entity_get_info()
DrupalDefaultEntityController::cleanIds in includes/entity.inc
Ensures integer entity IDs are valid.
DrupalDefaultEntityController::__construct in includes/entity.inc
Constructor: sets basic variables.
EnableDisableTestCase::testEntityInfoChanges in modules/system/system.test
Ensures entity info cache is updated after changes.
EntityFieldQuery::propertyQuery in includes/entity.inc
Queries entity tables in SQL for property conditions and sorts.
entity_cache_test_watchdog in modules/simpletest/tests/entity_cache_test.module
Implements hook_watchdog().

... See full list

1 string reference to 'entity_get_info'
entity_info_cache_clear in includes/common.inc
Resets the cached information about entity types.


includes/common.inc, line 7833
Common functions that many Drupal modules will need to reference.


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,
          'field cache' => TRUE,
          'load hook' => $name . '_load',
          'bundles' => array(),
          'view modes' => array(),
          'entity keys' => array(),
          'translation' => array(),
        $entity_info[$name]['entity keys'] += array(
          'revision' => '',
          'bundle' => '',
        foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
          $entity_info[$name]['view modes'][$view_mode] += array(
            'custom settings' => FALSE,

        // If no bundle key is provided, assume a single bundle, named after
        // the entity type.
        if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
          $entity_info[$name]['bundles'] = array(
            $name => array(
              'label' => $entity_info[$name]['label'],

        // Prepare entity schema fields SQL info for
        // DrupalEntityControllerInterface::buildQuery().
        if (isset($entity_info[$name]['base table'])) {
          $entity_info[$name]['base table field types'] = drupal_schema_field_types($entity_info[$name]['base table']);
          $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
          if (isset($entity_info[$name]['revision table'])) {
            $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);

      // 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];


alberto56’s picture

I have found that entity_get_info() sends back a translated label for User entities (there is only one: user), but not for node type entities (such as Basic page, Article).

HeFesT’s picture

Hi, I'm new to Drupal and the Entity API (just following drupalize.me series), but I think you had expect the keys 'Article' and 'Basic Page' to be in the returning array of get_entity_info(). (If I've understood correctly)

But those are just bundles (subtipos) of the Node Entity, so you can find them in the property 'bundles' of the Node Entity.

joachim’s picture

On Drupal 8:

// All definitions.
$entity_types = \Drupal::entityManager()->getDefinitions();

// Single definition.
$my_entity_type = \Drupal::entityManager()->getDefinition('my_entity_type');

Bearing in mind that you should inject the service instead of doing \Drupal::entityManager() if you can.

colan’s picture

I think it should be entityTypeManager() now, not entityManager(). So we should have the following instead:

$my_entity_type = \Drupal::entityTypeManager()->getDefinition('my_entity_type');