public function LTIToolProviderConsumerEntityController::save

cis7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)
cle7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)
elmsmedia7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)
icor7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)
meedjum_blog7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)
mooc7 LTIToolProviderConsumerEntityController.class.php public LTIToolProviderConsumerEntityController::save($entity)

Save a consumer.

Parameters

object $entity: The consumer.

Return value

object|boolean The consumer or false if save failed.

Overrides LTIToolProviderConsumerEntityControllerInterface::save

File

sites/all/modules/ulmus/lti_tool_provider/LTIToolProviderConsumerEntityController.class.php, line 66
Contains LTIToolProviderConsumerEntityController.

Class

LTIToolProviderConsumerEntityController

Code

public function save($entity) {
  $transaction = db_transaction();
  try {
    $entity->is_new = empty($enity->lti_tool_provider_consumer_id);
    if (empty($entity->date_joined)) {
      $entity->date_joined = REQUEST_TIME;
    }
    field_attach_presave('lti_tool_provider_consumer', $entity);
    $primary_key = $entity->lti_tool_provider_consumer_id ? 'lti_tool_provider_consumer_id' : array();
    if (empty($primary_key)) {
      drupal_write_record('lti_tool_provider_consumer', $entity);
      field_attach_insert('lti_tool_provider_consumer', $entity);
      $op = 'insert';
    }
    else {
      drupal_write_record('lti_tool_provider_consumer', $entity, $primary_key);
      $op = 'update';
    }
    $function = 'field_attach_' . $op;
    $function('lti_tool_provider_consumer', $entity);
    module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_consumer');
    unset($entity->is_new);
    db_ignore_slave();
    return $entity;
  }
  catch (Exception $e) {
    $transaction->rollback();
    drupal_set_message(t('%e', array('%e' => $entity->$e)));
    watchdog_exception('lti_tool_provider_consumer', $e, NULL, WATCHDOG_ERROR);
    return FALSE;
  }
}