You are here

public function EntityMetadataWrapper::value in Entity API 7

Returns the wrapped data. If no options are given the data is returned as described in the info.

Parameters

$options: (optional) A keyed array of options:

  • sanitize: A boolean flag indicating that textual properties should be sanitized for display to a web browser. Defaults to FALSE.
  • decode: If set to TRUE and some textual data is already sanitized, it strips HTML tags and decodes HTML entities. Defaults to FALSE.

Return value

mixed|null The value of the wrapped data. If the data property is not set, NULL is returned.

Throws

EntityMetadataWrapperException In case there are no data values available to the wrapper, an exception is thrown. E.g. if the value for an entity property is to be retrieved and there is no entity available, the exception is thrown. However, if an entity is available but the property is not set, NULL is returned.

14 calls to EntityMetadataWrapper::value()
EntityDrupalWrapper::value in includes/entity.wrapper.inc
Overridden.
EntityListWrapper::get in includes/entity.wrapper.inc
Get the wrapper for a single item.
EntityListWrapper::getIterator in includes/entity.wrapper.inc
If we wrap a list, we return an iterator over the data list.
EntityListWrapper::getPropertyValue in includes/entity.wrapper.inc
EntityListWrapper::label in includes/entity.wrapper.inc
Returns the label for the list of set values if available.

... See full list

3 methods override EntityMetadataWrapper::value()
EntityDrupalWrapper::value in includes/entity.wrapper.inc
Overridden.
EntityListWrapper::value in includes/entity.wrapper.inc
Returns the list as numerically indexed array.
EntityValueWrapper::value in includes/entity.wrapper.inc
Overrides EntityMetadataWrapper#value(). Sanitizes or decode textual data if necessary.

File

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

Class

EntityMetadataWrapper
A common base class for all wrappers.

Code

public function value(array $options = array()) {
  if (!$this
    ->dataAvailable() && isset($this->info['parent'])) {
    throw new EntityMetadataWrapperException('Missing data values.');
  }
  if (!isset($this->data) && isset($this->info['name'])) {
    $this->data = $this->info['parent']
      ->getPropertyValue($this->info['name'], $this->info);
  }
  return $this->data;
}