DataFormatter
abstract class DataFormatter (View source)
A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output format, and vice versa. This is most commonly used in developing RESTful APIs.
Traits
Provides extensions to this object to integrate it with standard config API methods.
Properties
int | $relationDepth | Follow relations for the {@link DataObject} instances ($has_one, $has_many, $many_many). |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Get a DataFormatter object suitable for handling the given file extension.
Get formatter for the first matching extension.
Get a DataFormatter object suitable for handling the given mimetype.
Get formatter for the first matching mimetype.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Return an array of the extensions that this data formatter supports
No description
Convert a single data object to this format. Return a string.
Convert an array to this format. Return a string.
No description
Convert an array of aliased field names to their Dataobject field name
Get the DataObject field name from its alias
Get a DataObject Field's Alias defaults to the fieldname
Details
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
stat(string $name)
deprecated
deprecated
Get inherited config value
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
$this
set_stat(string $name, mixed $value)
deprecated
deprecated
Update the config value for a given property
static DataFormatter
for_extension(string $extension)
Get a DataFormatter object suitable for handling the given file extension.
static DataFormatter
for_extensions(array $extensions)
Get formatter for the first matching extension.
static DataFormatter
for_mimetype(string $mimeType)
Get a DataFormatter object suitable for handling the given mimetype.
static DataFormatter
for_mimetypes(array $mimetypes)
Get formatter for the first matching mimetype.
Useful for HTTP Accept headers which can contain multiple comma-separated mimetypes.
$this
setCustomFields(array $fields)
array
getCustomFields()
$this
setCustomAddFields(array $fields)
$this
setCustomRelations(array $relations)
array
getCustomRelations()
array
getCustomAddFields()
$this
setRemoveFields(array $fields)
array
getRemoveFields()
string
getOutputContentType()
$this
setTotalSize(int $size)
int
getTotalSize()
abstract
supportedExtensions()
Return an array of the extensions that this data formatter supports
abstract
supportedMimeTypes()
abstract mixed
convertDataObject(DataObjectInterface $do)
Convert a single data object to this format. Return a string.
abstract string
convertDataObjectSet(SS_List $set)
Convert a data object set to this format. Return a string.
abstract string
convertArray($array)
Convert an array to this format. Return a string.
convertStringToArray(string $strData)
string[]
getRealFields(string $className, string[] $fields)
Convert an array of aliased field names to their Dataobject field name
string
getRealFieldName(string $className, string $field)
Get the DataObject field name from its alias
string
getFieldAlias(string $className, string $field)
Get a DataObject Field's Alias defaults to the fieldname