mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added DataObjectInterface, which other classes can implement to hook into DataObject::get
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@46057 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2ccd4c06ee
commit
6b4623973d
@ -8,7 +8,7 @@
|
||||
/**
|
||||
* A single database record & abstract class for the data-access-model.
|
||||
*/
|
||||
class DataObject extends Controller {
|
||||
class DataObject extends Controller implements DataObjectInterface {
|
||||
/**
|
||||
* Data stored in this objects database record. An array indexed
|
||||
* by fieldname.
|
||||
|
47
core/model/DataObjectInterface.php
Executable file
47
core/model/DataObjectInterface.php
Executable file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DataObjectInterface is an interface that other data systems in your application can implement in order to behave in a manner
|
||||
* similar to DataObject.
|
||||
*
|
||||
* In addition to the methods defined below, the data of the object should be directly accessible as fields.
|
||||
*/
|
||||
interface DataObjectInterface {
|
||||
/**
|
||||
* Create a new data object, not yet in the database. To load an object into the database, a null object should be constructed,
|
||||
* its fields set, and the write() method called.
|
||||
*/
|
||||
function __construct();
|
||||
|
||||
/**
|
||||
* Perform a search query on this data source
|
||||
*
|
||||
* @param $filter A filter expression of some kind, in SQL format.
|
||||
* @param $sort A sort expression, in SQL format.
|
||||
* @param $join A join expression. May or may not be relevant.
|
||||
* @param $limit A limit expression, either "(count)", or "(start), (count)"
|
||||
*/
|
||||
function instance_get($filter = "", $sort = "", $join = "", $limit = "", $containerClass = "DataObjectSet");
|
||||
|
||||
/**
|
||||
* Retrieve a single record from this data source
|
||||
*
|
||||
* @param $filter A filter expression of some kind, in SQL format.
|
||||
* @param $sort A sort expression, in SQL format.
|
||||
* @param $join A join expression. May or may not be relevant.
|
||||
* @param $limit A limit expression, either "(count)", or "(start), (count)"
|
||||
*/
|
||||
function instance_get_one($filter, $sort = "");
|
||||
|
||||
/**
|
||||
* Write the current object back to the database. It should know whether this is a new object, in which case this would
|
||||
* be an insert command, or if this is an existing object queried from the database, in which case thes would be
|
||||
*/
|
||||
function write();
|
||||
|
||||
/**
|
||||
* Remove this object from the database. Doesn't do anything if this object isn't in the database.
|
||||
*/
|
||||
function delete();
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user