Skip to content

Instantly share code, notes, and snippets.

@blockjon
Created December 3, 2014 19:29
Show Gist options
  • Save blockjon/de5088b8ec34b7e7cf1d to your computer and use it in GitHub Desktop.
Save blockjon/de5088b8ec34b7e7cf1d to your computer and use it in GitHub Desktop.
// Get a detached document from cache
$someDude = ....; // Pull a detached document from the cache with name "John"
// Use the postupdate annotation feature to trigger a call to sayMyName()
// which simply echo's this persons name to stdout.
$someDude->queuePostUpdateEvent(
$someDude,
'sayMyName',
array()
);
// Get the managed version of this document
$mergedDocument = $documentManager->merge($someDude);
// Set the person's name to santa claus.
$mergedDocument->setFirstName("Santa Claus");
// Capture the output of what sayMyName() echos out
ob_start();
$documentManager->flush($mergedDocument);
$output = ob_get_clean();
$this->assertEquals("John", $output); // <- Returns true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment