Gets the entity definition for an entity type.
string|null $entity_type: (optional) The entity type (e.g. 'node'). Leave NULL to retrieve information for all entity types.
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.
\Drupal\Core\Entity\EntityManager
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];
}
}