diff --git a/includes/entity.inc b/includes/entity.inc index 2fe9997..5442f69 100644 --- a/includes/entity.inc +++ b/includes/entity.inc @@ -31,6 +31,7 @@ class Entity { protected $entityInfo; protected $idKey, $nameKey, $statusKey; protected $defaultLabel = FALSE; + protected $wrapper; /** * Creates a new entity. @@ -112,6 +113,19 @@ class Entity { } /** + * Returns the EntityMetadataWrapper of the entity. + * + * @return EntityMetadataWrapper + * The EntityMetadataWrapper object built from the entity. + */ + public function wrapper() { + if (empty($this->wrapper)) { + $this->wrapper = entity_metadata_wrapper($this->entityType, $this); + } + return $this->wrapper; + } + + /** * Returns the label of the entity. * * Modules may alter the label by specifying another 'label callback' using