function entity_get_info

Gets the entity definition for an entity type.

Parameters

string|null $entity_type: (optional) The entity type (e.g. 'node'). Leave NULL to retrieve information for all entity types.

Return value

array An array containing the entity type's definition, as retrieved with \Drupal\Core\Entity\EntityManager. If $entity_type is NULL, an associative array of all entity type definitions keyed by entity type is returned.

See also

\Drupal\Core\Entity\EntityManager

hook_entity_info_alter()

69 calls to entity_get_info()
ConfigStorageController::__construct in drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
Implements Drupal\Core\Entity\EntityStorageControllerInterface::__construct().
config_get_module_config_entities in drupal/core/includes/config.inc
Return a list of all config entity types provided by a module.
DatabaseStorageController::__construct in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
Constructs a DatabaseStorageController object.
DisplayOverview::form in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Overrides Drupal\field_ui\OverviewBase::form().
DisplayOverview::submit in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Overrides Drupal\field_ui\OverviewBase::submit().

... See full list

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

File

drupal/core/includes/entity.inc, line 27
Entity API for handling entities like nodes or users.

Code

function entity_get_info($entity_type = NULL) {

  // 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'];
  if (empty($entity_info)) {
    $entity_info = drupal_container()
      ->get('plugin.manager.entity')
      ->getDefinitions();
  }
  if (empty($entity_type)) {
    return $entity_info;
  }
  elseif (isset($entity_info[$entity_type])) {
    return $entity_info[$entity_type];
  }
}