You are here

function context_pack_context in Context 6.2

Same name and namespace in other branches
  1. 6 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 285

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;
  $serialized = drupal_clone($context);

  // Clear out non-condition/reaction attributes
  unset($serialized->cid, $serialized->namespace, $serialized->attribute, $serialized->value, $serialized->type, $serialized->status);

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