You are here

public function EntityMetadataWrapper::set in Entity API 7

Set a new data value.

3 calls to EntityMetadataWrapper::set()
EntityListWrapper::set in includes/entity.wrapper.inc
Set a new data value.
EntityMetadataWrapper::__construct in includes/entity.wrapper.inc
Construct a new wrapper object.
EntityStructureWrapper::setProperty in includes/entity.wrapper.inc
Sets a property.
2 methods override EntityMetadataWrapper::set()
EntityDrupalWrapper::set in includes/entity.wrapper.inc
Overridden to support setting the entity by either the object or the id.
EntityListWrapper::set in includes/entity.wrapper.inc
Set a new data value.

File

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

Class

EntityMetadataWrapper
A common base class for all wrappers.

Code

public function set($value) {
  if (!$this
    ->validate($value)) {
    throw new EntityMetadataWrapperException(t('Invalid data value given. Be sure it matches the required data type and format. Value at !location: !value.', array(
      // An exception's message is output through check_plain().
      '!value' => is_array($value) || is_object($value) ? var_export($value, TRUE) : $value,
      '!location' => $this
        ->debugIdentifierLocation(),
    )));
  }
  $this
    ->clear();
  $this->data = $value;
  $this
    ->updateParent($value);
  return $this;
}