Skip to content

Instantly share code, notes, and snippets.

@jessebeach
Created November 9, 2012 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessebeach/4048393 to your computer and use it in GitHub Desktop.
Save jessebeach/4048393 to your computer and use it in GitHub Desktop.
entity_get_controller#entity.inc
/**
* Gets the entity controller class for an entity type.
*
* @return Drupal\Core\Entity\EntityStorageControllerInterface
*/
function entity_get_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
if (!isset($controllers[$entity_type])) {
$type_info = entity_get_info($entity_type);
$class = $type_info['controller_class'];
$controllers[$entity_type] = new $class($entity_type);
}
return $controllers[$entity_type];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment