You are here

public function EntityValueWrapper::value in Entity API 7

Overrides EntityMetadataWrapper#value(). Sanitizes or decode textual data if necessary.

Overrides EntityMetadataWrapper::value

File

includes/entity.wrapper.inc, line 274
Provides wrappers allowing easy usage of the entity metadata.

Class

EntityValueWrapper
Wraps a single value.

Code

public function value(array $options = array()) {
  $data = parent::value();
  if ($this->type == 'text' && isset($data)) {
    $info = $this->info + array(
      'sanitized' => FALSE,
      'sanitize' => 'check_plain',
    );
    $options += array(
      'sanitize' => FALSE,
      'decode' => FALSE,
    );
    if ($options['sanitize'] && !$info['sanitized']) {
      return call_user_func($info['sanitize'], $data);
    }
    elseif ($options['decode'] && $info['sanitized']) {
      return decode_entities(strip_tags($data));
    }
  }
  return $data;
}