You are here

function _entity_token_wrap_data in Entity API 7

Wraps the given data by correctly obeying the options.

1 call to _entity_token_wrap_data()
entity_token_tokens in ./entity_token.tokens.inc
Implements hook_tokens().

File

./entity_token.tokens.inc, line 277
Provides tokens for entity properties which have no token yet.

Code

function _entity_token_wrap_data($token_type, $type, $data, $options) {
  if ($type == 'site') {
    $wrapper = entity_metadata_site_wrapper();
  }
  elseif ($type == 'struct') {

    // 'struct' data items are passed on wrapped.
    $wrapper = $data;
  }
  else {
    $wrapper = entity_metadata_wrapper($type, $data);
  }
  if (isset($options['language']) && $wrapper instanceof EntityStructureWrapper) {
    $wrapper
      ->language($options['language']->language);
  }
  return $wrapper;
}