You are here

public function EntityMetadataWrapper::label in Entity API 7

Returns the label for the currently set property value if there is one available, i.e. if an options list has been specified.

2 methods override EntityMetadataWrapper::label()
EntityDrupalWrapper::label in includes/entity.wrapper.inc
Returns the entity label.
EntityListWrapper::label in includes/entity.wrapper.inc
Returns the label for the list of set values if available.

File

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

Class

EntityMetadataWrapper
A common base class for all wrappers.

Code

public function label() {
  if ($options = $this
    ->optionsList('view')) {
    $options = entity_property_options_flatten($options);
    $value = $this
      ->value();
    if (is_scalar($value) && isset($options[$value])) {
      return $options[$value];
    }
  }
}