Drupal - Is there a good way to inspect objects whose type is derived from the EntityDrupalWrapper class?

Use dpm($wrapper->getPropertyInfo());

It's in the docs.


I had been playing with EntityDrupalWrapper objects. debug() usually returns the output that may have prepared by __toString()

I iterated EntityDrupalWrapper object using foreach and it helped to list down the name of properties.

foreach($order_wrapper as $name => $obj){
  debug($name);
  debug(get_class($obj)); //EntityValueWrapper
}

Here $obj is an object of type EntityValueWrapper

$obj can be read by $obj->value() and can be write by $obj->set('value');

EDIT:

If you have created your wrapper without passing second param
i.e. entity_metadata_wrapper('commerce_order');
then set and value methods will throw exception as they are not implemented.


I wound up writing my own little widget to unroll the wrapper:

function _wrapper_debug($w) {
  $values = array();
  foreach ($w->getPropertyInfo() as $key => $val) {
    $values[$key] = $w->$key->value();
  }
  return $values;
}

dpm(_wrapper_debug($some_object_wrapper));

Hope someone finds it useful.