2007-11-30 03:58:56 +01:00
|
|
|
<?php
|
2016-06-15 06:03:16 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\ORM;
|
|
|
|
|
2014-08-15 08:53:05 +02:00
|
|
|
/**
|
2012-09-26 23:34:00 +02:00
|
|
|
* DataObjectInterface is an interface that other data systems in your application can implement in order to behave in
|
|
|
|
* a manner similar to DataObject.
|
2007-11-30 03:58:56 +01:00
|
|
|
*
|
|
|
|
* In addition to the methods defined below, the data of the object should be directly accessible as fields.
|
|
|
|
*/
|
|
|
|
interface DataObjectInterface {
|
|
|
|
/**
|
2012-09-26 23:34:00 +02:00
|
|
|
* 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.
|
2007-11-30 03:58:56 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function __construct();
|
2007-11-30 03:58:56 +01:00
|
|
|
|
|
|
|
/**
|
2012-09-26 23:34:00 +02:00
|
|
|
* 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
|
2014-08-15 08:53:05 +02:00
|
|
|
* be
|
2007-11-30 03:58:56 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function write();
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2007-11-30 03:58:56 +01:00
|
|
|
/**
|
|
|
|
* Remove this object from the database. Doesn't do anything if this object isn't in the database.
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function delete();
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2007-12-04 05:07:04 +01:00
|
|
|
/**
|
|
|
|
* Get the named field.
|
|
|
|
* This function is sometimes called explicitly by the form system, so you need to define it, even if you use the
|
|
|
|
* default field system.
|
2016-08-19 00:51:35 +02:00
|
|
|
*
|
|
|
|
* @param string $fieldName
|
|
|
|
* @return mixed
|
2007-12-04 05:07:04 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function __get($fieldName);
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2007-12-04 05:07:04 +01:00
|
|
|
/**
|
|
|
|
* Save content from a form into a field on this data object.
|
|
|
|
* Since the data comes straight from a form it can't be trusted and will need to be validated / escaped.'
|
2016-08-19 00:51:35 +02:00
|
|
|
*
|
|
|
|
* @param string $fieldName
|
|
|
|
* @param mixed $val
|
|
|
|
* @return $this
|
2007-12-04 05:07:04 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function setCastedField($fieldName, $val);
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|