mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE: Removed DataObjectLog class, the same functionality should be implemented using extensions.
This commit is contained in:
parent
381e952aaf
commit
e8dd38eac3
@ -974,7 +974,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* - All relevant tables will be updated.
|
* - All relevant tables will be updated.
|
||||||
* - $this->onBeforeWrite() gets called beforehand.
|
* - $this->onBeforeWrite() gets called beforehand.
|
||||||
* - Extensions such as Versioned will ammend the database-write to ensure that a version is saved.
|
* - Extensions such as Versioned will ammend the database-write to ensure that a version is saved.
|
||||||
* - Calls to {@link DataObjectLog} can be used to see everything that's been changed.
|
|
||||||
*
|
*
|
||||||
* @uses DataExtension->augmentWrite()
|
* @uses DataExtension->augmentWrite()
|
||||||
*
|
*
|
||||||
@ -1116,13 +1115,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
DB::manipulate($manipulation);
|
DB::manipulate($manipulation);
|
||||||
|
|
||||||
if(isset($isNewRecord) && $isNewRecord) {
|
|
||||||
DataObjectLog::addedObject($this);
|
|
||||||
} else {
|
|
||||||
DataObjectLog::changedObject($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->onAfterWrite();
|
$this->onAfterWrite();
|
||||||
|
|
||||||
$this->changed = null;
|
$this->changed = null;
|
||||||
@ -1212,8 +1204,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
|
|
||||||
$this->OldID = $this->ID;
|
$this->OldID = $this->ID;
|
||||||
$this->ID = 0;
|
$this->ID = 0;
|
||||||
|
|
||||||
DataObjectLog::deletedObject($this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,113 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* A DataObjectLog is a log of changes that have been made to the database in this session.
|
|
||||||
* It was designed to help with updates to the CMS tree, and could be used wherever an Ajax call
|
|
||||||
* needs to update a complex on-screen representation of your data.
|
|
||||||
* @package sapphire
|
|
||||||
* @subpackage model
|
|
||||||
*/
|
|
||||||
class DataObjectLog extends Object {
|
|
||||||
/**
|
|
||||||
* This must be set to true for the DataObjectLog to work
|
|
||||||
*/
|
|
||||||
static $enabled = false;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataObjects that have been added to the database in this session.
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
static $added = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataObjects that have been deleted from the database in this session.
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
static $deleted = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataObjects that have been changed in the database in this session.
|
|
||||||
*/
|
|
||||||
static $changed = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add this DataObject as added in the log.
|
|
||||||
* @param DataObject $object
|
|
||||||
*/
|
|
||||||
static function addedObject($object) {
|
|
||||||
if(self::$enabled) {
|
|
||||||
self::$added[$object->class][] = $object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add this DataObject as deleted in the log.
|
|
||||||
* @param DataObject $object
|
|
||||||
*/
|
|
||||||
static function deletedObject($object) {
|
|
||||||
if(self::$enabled) {
|
|
||||||
self::$deleted[$object->class][] = $object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add this DataObject as changed in the log.
|
|
||||||
* @param DataObject $object
|
|
||||||
*/
|
|
||||||
static function changedObject($object) {
|
|
||||||
if(self::$enabled) {
|
|
||||||
self::$changed[$object->class][] = $object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all DataObjects that have been added this session that are of
|
|
||||||
* the class or a subclass of the class provided.
|
|
||||||
* @param string $className The class name.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function getAdded($className) {
|
|
||||||
return self::getByClass($className, self::$added);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all DataObjects that have been deleted this session that are of
|
|
||||||
* the class or a subclass of the class provided.
|
|
||||||
* @param string $className The class name.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function getDeleted($className) {
|
|
||||||
return self::getByClass($className, self::$deleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all DataObjects that have been changed this session that are of
|
|
||||||
* the class or a subclass of the class provided.
|
|
||||||
* @param string $className The class name.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function getChanged($className) {
|
|
||||||
return self::getByClass($className, self::$changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all DataObjects in the given set that are of the class or a
|
|
||||||
* subclass of the class provided.
|
|
||||||
* @param string $className The class name.
|
|
||||||
* @param array $set The set to search in.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function getByClass($className, $set) {
|
|
||||||
$allClasses = ClassInfo::subclassesFor($className);
|
|
||||||
foreach($allClasses as $subClass) {
|
|
||||||
if(isset($set[$subClass])) {
|
|
||||||
foreach($set[$subClass] as $page) {
|
|
||||||
$result[$page->ID] = $page;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isset($result) ? $result : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user