You are here

protected function CommerceLicenseEntityController::saveRevision in Commerce License 7

Overrides EntityBundlePluginEntityController::saveRevision().

Maintains the revision_created and revision_ended timestamps and the revision_uid column.

Overrides EntityAPIController::saveRevision

File

includes/commerce_license.controller.inc, line 31
Controller for the commerce_license entity type.

Class

CommerceLicenseEntityController
@file Controller for the commerce_license entity type.

Code

protected function saveRevision($entity) {
  if ($entity->is_new_revision) {
    $current_time = commerce_license_get_time();
    $entity->revision_created = $current_time;
    $entity->revision_ended = 0;
    $entity->revision_uid = $GLOBALS['user']->uid;

    // Clear the log if it's unset, or the same as the previous revision's.
    if (empty($entity->log) || $entity->log == $entity->original->log) {
      $entity->log = '';
    }

    // A previous revision exists, close it.
    if (!empty($entity->revision_id)) {
      db_update($this->revisionTable)
        ->fields(array(
        'revision_ended' => $current_time - 1,
      ))
        ->condition('revision_id', $entity->revision_id)
        ->execute();
    }
  }
  parent::saveRevision($entity);
}