webCOMAND

Content::get_saved_history()

Get an array of metadata about past versions of the content.

Prototype

array get_saved_history()

Return

Array of associative arrays that contain the following metadata for each version in the version history for this content, newest first.  The keys that start with an underscore character ('_') are for internal use and generally can not be relied upon to continue to exist in future releases.

  • ContentTypeID - The ID of the content type.  This can be used to retrieve the version of the content with repo::get_object_stub_by_id();
  • ID - The ID of the revision.  This can be used to retrieve the version of the content with repo::get_object_stub_by_id();
  • _FieldID - ID of the field this content is embedded under.
  • _ParentType - ID of the parent content's content type this object is embedded under.
  • _ParentID - ID of the parent object this content is embedded under.
  • _ActiveID - Always 1, which indicates a past version of the object.
  • _RealID - The actual ID of the object (same across revisions).
  • _StartRevision - The revision number this record was created.
  • _EndRevision - The revision number this record was retired.
  • _EndDraftRevision - The revision number this record was expired as a draft.
  • _LastModified - Timestamp the record was created, including microseconds when available.

Example

$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact LIMIT 1');
echo("Contact First Name: $contact->FirstName\n");
$history = $contact->get_saved_history();
foreach($history as $i=>$h) {
    $rev = $repo->get_object_stub_by_id($h['ContentTypeID'], $h['ID']);
    echo("  Revision $i First Name: $rev->FirstName\n");
}