1 entity.controller.inc public DefaultEntityController::__construct($entityType)

Implements EntityControllerInterface::__construct().

Sets basic variables.

Parameters

$entityType: The entity type for which the instance is created.

File

core/modules/entity/entity.controller.inc, line 146
Entity API controller classes and interface.

Class

DefaultEntityController
Defines a base entity controller class.

Code

public function __construct($entityType) {
  $this->entityType = $entityType;
  $this->entityInfo = entity_get_info($entityType);
  $this->entityCache = array();
  $this->hookLoadArguments = array();
  $this->idKey = $this->entityInfo['entity keys']['id'];

  // Check if the entity type supports revisions.
  if (!empty($this->entityInfo['entity keys']['revision'])) {
    $this->revisionKey = $this->entityInfo['entity keys']['revision'];
    $this->revisionTable = $this->entityInfo['revision table'];
  }
  else {
    $this->revisionKey = FALSE;
  }

  // Check if the entity type supports static caching of loaded entities.
  $this->staticCache = !empty($this->entityInfo['static cache']);

  // Check if the entity type supports usage of the persistent entity cache.
  if (isset($this->entityInfo['entity cache'])
   && $this->entityInfo['entity cache']
     && db_table_exists('cache_entity_' . $this->entityType)) {
    $this->persistentCache = TRUE;
  }
  else {
    $this->persistentCache = FALSE;
  }
}