Since the $user object is partail when doing global $user, I find myself needing to user_load() it before. It would be nice if the signature was:

entity_metadata_wrapper(($type, $data = NULL, array $info = array(), $reload = TRUE) {
  if ($reload && !empty($data)) {
    $object = reset(entity_load($type, array($data)));
  }

makes sense? roll a patch?

Comments

fago’s picture

Hm, not really as this function is also used for non entities. But I agree that might be useful, so best let's add a separate function that just takes the entity id for that.

Anyway imho it would make sense to support lazy-loading lists of referenced entities - theoretically important when the list become huge. Don't know whether this is going to be the case though, if it is I think it should be doable by using an object implementing ArrayAccess instead of a plain array.

fago’s picture

Status: Active » Fixed

>Anyway imho it would make sense to support lazy-loading lists of referenced entities - theoretically important when the list become huge.

I just made that possible easily as entities are internally treated by their ids now. :) Also you may create the wrapper by passing the id, e.g.:

$wrapper = entity_metadata_wrapper('user', $GLOBALS['user']->uid);

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.