API

Entity API new helper method

With new release(v1.6) of Entity API module we received not only a security fix but a small but very helpful method of an Entity class.

Before this release when you want to get an entity wrapper you have to do something like this:

// Each function needing it creates a new EntityMetadataWrapper class.
$wrapper = entity_metadata_wrapper($entity->entityType(), $entity);

With this new method:

// Uses always the same EntityMetadataWrapper class because it is stored in the Entity itself.
$wrapper = $entity->wrapper();

As you can see it's a really small change, but still it's very useful!