You are here

public function EntityShareEntityExport::__construct in Entity Share 7

Constructor. Initialize properties.

Parameters

object $entity: Entity to export.

Overrides EntityShareEntityAbstract::__construct

File

includes/entity_share.entity.export.inc, line 20
Class for handling Entity Export.

Class

EntityShareEntityExport
Manage general entity export.

Code

public function __construct($entity) {
  if (empty($entity)) {
    throw new EntityShareExportException('Entity can\\t be empty.');
  }
  parent::__construct($entity);

  // Add a entity_share property to the entity.
  if (!isset($entity->entity_share)) {
    $entity->entity_share = new stdClass();
  }

  // Reset the static cache of the entity to avoid invalid
  // entity problem (without id) when multiple exports of
  // the same entity (ex: taxonomy term etc).
  entity_get_controller($entity->entity_type)
    ->resetCache();
}