mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: added isLatestVersion() method for checking whether a record is the latest version of this ID
This commit is contained in:
parent
4448325ad3
commit
4c6ddb142d
@ -953,6 +953,22 @@ class Versioned extends DataExtension {
|
|||||||
return new $className($record);
|
return new $className($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the current record is the latest one.
|
||||||
|
*
|
||||||
|
* @todo Performance - could do this directly via SQL.
|
||||||
|
*
|
||||||
|
* @see get_latest_version()
|
||||||
|
* @see latestPublished
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function isLatestVersion() {
|
||||||
|
$version = self::get_latest_version($this->owner->class, $this->owner->ID);
|
||||||
|
|
||||||
|
return ($version->Version == $this->owner->Version);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the equivalent of a DataObject::get() call, querying the latest
|
* Return the equivalent of a DataObject::get() call, querying the latest
|
||||||
* version of each page stored in the (class)_versions tables.
|
* version of each page stored in the (class)_versions tables.
|
||||||
@ -1055,8 +1071,10 @@ class Versioned extends DataExtension {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single version of a record.
|
* Represents a single version of a record.
|
||||||
|
*
|
||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage model
|
* @subpackage model
|
||||||
|
*
|
||||||
* @see Versioned
|
* @see Versioned
|
||||||
*/
|
*/
|
||||||
class Versioned_Version extends ViewableData {
|
class Versioned_Version extends ViewableData {
|
||||||
|
Loading…
Reference in New Issue
Block a user