You are here

public function EntityDrupalWrapper::__sleep in Entity API 7

Prepare for serializiation.

Overrides EntityStructureWrapper::__sleep

File

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

Class

EntityDrupalWrapper
Provides a wrapper for entities registrered in hook_entity_info().

Code

public function __sleep() {
  $vars = parent::__sleep();

  // Don't serialize the loaded entity and its property info.
  unset($vars['data'], $vars['propertyInfo'], $vars['propertyInfoAltered'], $vars['entityInfo']);

  // In case the entity is not saved yet, serialize the unsaved data.
  if ($this
    ->dataAvailable() && $this->id === FALSE) {
    $vars['data'] = 'data';
  }
  return $vars;
}