Class Versioned
The Versioned decorator allows your DataObjects to have several versions, allowing you to rollback changes and view history. An example of this is the pages used in the CMS.
- Extension
-
DataObjectDecorator
-
Versioned
Methods summary
public static
|
|
public
|
|
public
array
|
|
public
|
|
public static
|
|
protected static
|
#
requireArchiveTempTable( string $baseTable, string $date = null )
Create a temporary table mapping each database record to its version on the given date. This is used by the versioning system to return database content on that date. |
public
|
|
public
|
|
public
|
#
onAfterSkippedWrite( )
If a write was skipped, then we need to ensure that we don't leave a migrateVersion() value lying around for the next write. |
public
boolean
|
#
canBeVersioned( string $table )
Determine if a table is supporting the Versioned extensions (e.g. $table_versions does exists) |
public
boolean
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
stagesDiffer( string $stage1, string $stage2 )
Compare two stages to see if they're different. Only checks the version numbers, not the actual content. |
public
|
|
public
|
#
allVersions( string $filter = "", mixed $sort = "", mixed $limit = "", mixed $join = "", mixed $having = "" )
Return a list of all the versions available. |
public
|
#
compareVersions( string $from, string $to )
Compare two version, and return the diff between them. |
public
string
|
|
public static
|
#
choose_site_stage( )
Choose the stage the site is currently on. If $_GET['stage'] is set, then it will use that stage, and store it in the session. if $_GET['archiveDate'] is set, it will use that date, and store it in the session. If neither of these are set, it checks the session, otherwise the stage is set to 'Live'. |
public static
|
|
public static
string
|
|
public static
string
|
|
public static
string
|
|
public static
string
|
|
public static
|
|
public static
|
|
public static
|
#
get_one_by_stage( string $class, string $stage, string $filter = '', boolean $cache = true, string $orderby = '' )
Get a singleton instance of a class in the given stage. |
public static
integer
|
#
get_versionnumber_by_stage( string $class, string $stage, integer $id, boolean $cache = true )
Gets the current version number of a specific record. |
public static
|
#
prepopulate_versionnumber_cache( mixed $class, mixed $stage, mixed $idList = null )
Pre-populate the cache for Versioned::get_versionnumber_by_stage() for a list of record IDs, for more efficient database querying. If $idList is null, then every page will be pre-cached. |
public static
|
#
get_by_stage( string $class, string $stage, string $filter = '', string $sort = '', string $join = '', integer $limit = '', string $containerClass = 'DataObjectSet' )
Get a set of class instances by the given stage. |
public
|
|
public
|
|
public
|
#
buildVersionSQL( mixed $filter = "", mixed $sort = "" )
Build a SQL query to get data from the _version table. This function is
similar in style to |
public static
|
|
public static
|
|
public static
|
#
get_including_deleted( mixed $class, mixed $filter = "", mixed $sort = "" )
Return the equivalent of a DataObject::get() call, querying the latest version of each page stored in the (class)_versions tables. |
public static
|
#
get_including_deleted_query( mixed $class, mixed $filter = "", mixed $sort = "" )
Return the query for the equivalent of a DataObject::get() call, querying the latest version of each page stored in the (class)_versions tables. |
public static
|
|
public static
|
|
public
|
|
public
|
|
public
|
#
updateFieldLabels( mixed & $labels )
this function is used to provide modifications to the fields labels in CMS by the decorator By default, the fieldLabels() of its owner will merge more fields defined in the decorator's $extra_fields['field_labels'] |
public
|
|
public
|
Methods inherited from DataObjectDecorator
can(),
canCreate(),
canDelete(),
canEdit(),
load_extra_statics(),
onAfterDelete(),
onAfterWrite(),
onBeforeDelete(),
onBeforeWrite(),
populateDefaults(),
requireDefaultRecords(),
updateCMSActions(),
updateCMSFields(),
updateFrontEndFields(),
updateSummaryFields()
Methods inherited from Extension
clearOwner(),
getOwner(),
get_classname_without_arguments(),
setOwner()
Magic methods summary
Properties summary
protected
array
|
$stages |
#
An array of possible stages. |
protected
string
|
$defaultStage |
#
The 'default' stage. |
protected
string
|
$liveStage |
#
The 'live' stage. |
public
string
|
$migratingVersion |
#
A version that a DataObject should be when it is 'migrating', that is, when it is in the process of moving from one stage to another. |
protected static
array
|
$cache_versionnumber |
#
A cache used by get_versionnumber_by_stage(). Clear through |
public static
array
|
$db_for_versions_table |
#
Additional database columns for the new "_versions" table. Used in |
public static
array
|
$indexes_for_versions_table |
#
Additional database indexes for the new "_versions" table. Used in |
public static
integer
|
$versions_ttl | |
protected static
array
|
$versionableExtensions |
#
An array of DataObject extensions that may require versioning for extra tables The array value is a set of suffixes to form these table names, assuming a preceding '_'. E.g. if Extension1 creates a new table 'Class_suffix1' and Extension2 the tables 'Class_suffix2' and 'Class_suffix3': |
protected static
mixed
|
$reading_mode |