You are here

public function CivicrmEntity::__construct in CiviCRM Entity 7.2

Same name and namespace in other branches
  1. 7 civicrm_entity.inc \CivicrmEntity::__construct()

Creates a new entity.

Overrides Entity::__construct

See also

entity_create()

File

./civicrm_entity.inc, line 13

Class

CivicrmEntity
@TODO Document this class.

Code

public function __construct(array $values = array(), $entityType = NULL) {
  if (empty($entityType)) {
    throw new Exception('Cannot create an instance of Entity without a specified entity type.');
  }
  $this->entityType = $entityType;
  $this
    ->setUp();

  // Set initial values.
  foreach ($values as $key => $value) {

    // this is a bit of a hack around the fact we are casting to this to construct it
    if (stristr($key, "\0")) {
      continue;
    }
    $this->{$key} = $value;
  }
}