You are here

class EntityValueWrapper in Entity API 7

Wraps a single value.

Hierarchy

Expanded class hierarchy of EntityValueWrapper

File

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

View source
class EntityValueWrapper extends EntityMetadataWrapper {

  /**
   * Overrides EntityMetadataWrapper#value().
   * Sanitizes or decode textual data if necessary.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityMetadataWrapper::$cache protected property
EntityMetadataWrapper::$data protected property
EntityMetadataWrapper::$info protected property
EntityMetadataWrapper::$type protected property 1
EntityMetadataWrapper::access public function Determines whether the given user has access to view or edit this property. Apart from relying on access metadata of properties, this takes into account information about entity level access, if available: 1
EntityMetadataWrapper::clear protected function Clears the data value and the wrapper cache. 1
EntityMetadataWrapper::dataAvailable protected function Returns whether data is available to work with.
EntityMetadataWrapper::debugIdentifierLocation public function Returns a string to use to identify this wrapper in error messages. 1
EntityMetadataWrapper::info public function Gets info about the wrapped data.
EntityMetadataWrapper::label public function Returns the label for the currently set property value if there is one available, i.e. if an options list has been specified. 2
EntityMetadataWrapper::optionsList public function Returns the options list specifying possible values for the property, if defined.
EntityMetadataWrapper::raw public function Returns the raw, unprocessed data. Most times this is the same as returned by value(), however for already processed and sanitized textual data, this will return the unprocessed data in contrast to value().
EntityMetadataWrapper::set public function Set a new data value. 2
EntityMetadataWrapper::type public function Gets the (entity)type of the wrapped data. 1
EntityMetadataWrapper::updateParent protected function Updates the parent data structure of a data property with the latest data value.
EntityMetadataWrapper::validate public function Returns whether $value is a valid value to set. 1
EntityMetadataWrapper::__construct public function Construct a new wrapper object. 2
EntityMetadataWrapper::__sleep public function Prepare for serializiation. 1
EntityMetadataWrapper::__toString public function
EntityValueWrapper::value public function Overrides EntityMetadataWrapper#value(). Sanitizes or decode textual data if necessary. Overrides EntityMetadataWrapper::value