Currently, EntityWrapper::getValue() relies on entity_load() and returns NULL if the entity hasn't been saved yet. This should be considered a bug because we need this to work with unsaved entities as well e.g. when passing a freshly created node object before saving it.
<?php
public function getValue() {
$source = $this->getIdSource();
$id = $source ? $source->getValue() : $this->id;
return $id ? entity_load($this->entityType, $id) : NULL;
}
?>
Originally reported by EclipseGc (following snippet currently fails):
<?php
$node = entity_create('node', array('type'=> 'page'));
$typed_data = typed_data()->create(
array(
'type'=> 'entity',
'constraints'=> array(
'EntityType'=> 'node',
),
),
$node
);
drupal_set_message('<pre>'. var_export($typed_data->getValue(), TRUE) . '</pre>');
?>