How to access a field value in hook_preprocess_eck_entity How can I access a field value in hook_preprocess_entity(&amp;$vars)?

I am able to do the following, but it does not seem like the best approach. What is a better approach?

function mymodule_preprocess_eck_entity(&amp;$vars) {
  $myvalue = $vars['content']['field_myfield'][0]['#context']['value'];
}
I found I can get the value with:

  $myvalue = $vars['eck_entity']-&gt;get('field_myfield')-&gt;getString();