You are here

function context_pack_context in Context 6

Same name and namespace in other branches
  1. 6.2 context.module \context_pack_context()

Helper function to pack a context object to be stored in the database.

1 call to context_pack_context()
context_save_context in ./context.module
Inserts or updates a context object into the database. @TODO: should probably return the new cid on success -- make sure this doesn't break any checks elsewhere.

File

./context.module, line 276

Code

function context_pack_context($context) {
  $packed = new StdClass();
  $packed->cid = $context->cid;
  $packed->namespace = $context->namespace;
  $packed->attribute = $context->attribute;
  $packed->value = $context->value;
  unset($context->cid);
  unset($context->namespace);
  unset($context->attribute);
  unset($context->value);

  // Clear out storage and status information
  unset($context->type);
  unset($context->status);

  // Serialize associations as data array
  $context = (array) $context;
  $packed->data = serialize($context);
  return $packed;
}