public function LTIToolProviderMembershipsContextEntityController::save

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

Save a memberships context entity.

Parameters

object $entity: The memberships context to be saved.

Return value

object|boolean The saved entity or FALSE.

Overrides LTIToolProviderMembershipsContextEntityControllerInterface::save

File

sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsContextEntityController.class.php, line 40
Contains LTIToolProviderMembershipsContextEntityController.

Class

LTIToolProviderMembershipsContextEntityController
Memberships Context Entity controller.

Code

public function save($entity) {
  $transaction = db_transaction();
  try {
    $entity->is_new = empty($entity->lti_tool_provider_memberships_context_id);
    field_attach_presave('lti_tool_provider_memberships_context', $entity);
    $primary_key = $entity->lti_tool_provider_memberships_context_id ? 'lti_tool_provider_memberships_context_id' : array();
    if (empty($primary_key)) {
      drupal_write_record('lti_tool_provider_memberships_context', $entity);
      field_attach_insert('lti_tool_provider_memberships_context', $entity);
      $op = 'insert';
    }
    else {
      drupal_write_record('lti_tool_provider_memberships_context', $entity, $primary_key);
      $op = 'update';
    }
    $function = 'field_attach_' . $op;
    $function('lti_tool_provider_memberships_context', $entity);
    module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_memberships_context');
    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_memberships_context', $e, NULL, WATCHDOG_ERROR);
    return FALSE;
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.