Example #1
-1
/**
 * Act on entities of a specific type when loaded.
 *
 * @param array $entities
 *   The entities keyed by entity ID.
 *
 * @ingroup entity_crud
 * @see hook_entity_load()
 */
function hook_ENTITY_TYPE_load($entities)
{
    foreach ($entities as $entity) {
        $entity->foo = mymodule_add_something($entity);
    }
}
Example #2
-1
/**
 * Act on entities when loaded.
 *
 * This is a generic load hook called for all entity types loaded via the
 * entity API.
 *
 * @param $entities
 *   The entities keyed by entity ID.
 * @param $type
 *   The type of entities being loaded (i.e. node, user, comment).
 */
function hook_entity_load($entities, $type)
{
    foreach ($entities as $entity) {
        $entity->foo = mymodule_add_something($entity, $type);
    }
}