You are here

public function EntityTranslationDefaultHandler::setEntity in Entity Translation 7

Overrides EntityTranslationHandlerInterface::setEntity

See also

EntityTranslationHandlerInterface::setEntity()

1 call to EntityTranslationDefaultHandler::setEntity()
EntityTranslationDefaultHandler::__construct in includes/translation.handler.inc
Initializes an instance of the translation handler.

File

includes/translation.handler.inc, line 1003
Default translation handler for the translation module.

Class

EntityTranslationDefaultHandler
Class implementing the default entity translation behaviours.

Code

public function setEntity($entity) {
  $this->entity = $entity;

  // Ensure translations data is populated.
  $translations_key = $this
    ->getTranslationsKey();
  if ($translations_key && !isset($this->entity->{$translations_key})) {
    $this->entity->{$translations_key} = self::emptyTranslations();
  }

  // Update entity properties.
  list($this->entityId, $this->revisionId, $this->bundle) = entity_extract_ids($this->entityType, $this->entity);

  // Initialize the handler id if needed.
  if (!empty($this->factory)) {
    $this->factory
      ->getHandlerId($this->entityType, $entity);
  }
}