Class DataFormatter
A DataFormatter object handles transformation of data from Sapphire model objects to a particular output format, and vice versa. This is most commonly used in developing RESTful APIs.
- Object
-
DataFormatter
Direct known subclasses
Indirect known subclasses
Methods summary
public static
|
#
for_extension( string $extension )
Get a DataFormatter object suitable for handling the given file extension. |
public static
|
|
public static
|
#
for_mimetype( string $mimeType )
Get a DataFormatter object suitable for handling the given mimetype. |
public static
|
#
for_mimetypes( array $mimetypes )
Get formatter for the first matching mimetype. Useful for HTTP Accept headers which can contain multiple comma-separated mimetypes. |
public
|
|
public
array
|
|
public
|
|
public
|
|
public
array
|
|
public
array
|
|
public
|
|
public
array
|
|
public
|
|
public
|
|
public
integer
|
|
protected
array
|
#
getFieldsForObj(
Returns all fields on the object which should be shown in the output. Can be
customised through |
abstract public
|
|
abstract public
|
|
abstract public
|
#
convertDataObject(
Convert a single data object to this format. Return a string. |
abstract public
|
#
convertDataObjectSet(
Convert a data object set to this format. Return a string. |
public
|
Methods inherited from Object
__call(),
__construct(),
__toString(),
__wakeup(),
addMethodsFrom(),
addStaticVars(),
addWrapperMethod(),
add_extension(),
add_static_var(),
allMethodNames(),
cacheToFile(),
cacheToFileWithArgs(),
clearCache(),
combined_static(),
create(),
createMethod(),
create_from_string(),
defineMethods(),
exists(),
extInstance(),
extend(),
getCustomClass(),
getExtensionInstance(),
getExtensionInstances(),
get_extensions(),
get_static(),
hasExtension(),
hasMethod(),
has_extension(),
invokeWithExtensions(),
is_a(),
loadCache(),
parentClass(),
parse_class_spec(),
remove_extension(),
sanitiseCachename(),
saveCache(),
set_stat(),
set_static(),
set_uninherited(),
stat(),
strong_create(),
uninherited(),
uninherited_static(),
useCustomClass()
Magic methods summary
Properties summary
public static
integer
|
$priority |
#
Set priority from 0-100. If multiple formatters for the same extension exist, we select the one with highest priority. |
public
integer
|
$relationDepth |
#
Follow relations for the |
protected
array
|
$customFields |
#
Allows overriding of the fields which are rendered for the processed
dataobjects. By default, this includes all fields in |
protected
array
|
$customAddFields |
#
Allows addition of fields (e.g. custom getters on a DataObject) |
protected
array
|
$customRelations |
#
Allows to limit or add relations. Only use in combination with |
protected
array
|
$removeFields |
#
Fields which should be expicitly excluded from the export. Comes in handy for
field-level permissions. Will overrule both |
protected
string
|
$outputContentType |
#
Specifies the mimetype in which all strings returned from the convert*() methods should be used, e.g. "text/xml". |
protected
integer
|
$totalSize |
#
Used to set totalSize properties on the output of |