\RESTFormatter
Synopsis
class RESTFormatter
{
- // members
- public static string $default = 'application/json';
- // methods
- private static void useful_mimetype()
- public static RESTFormatter get_formatter()
- private static array object_to_array()
- public array decodeFields()
- public void format()
- protected any collectFields()
- public abstract void dataItem()
- public abstract void addToItem()
- public abstract any addCollectionToItem()
- public abstract void appendToCollection()
- protected abstract SS_HTTPResponse buildResponse()
Members
public
- $default
Methods
private
- object_to_array() — Takes a possibly nested set of stdClass objects and turns it into a nested associative array
- useful_mimetype()
protected
- buildResponse() — Takes the noun we build the data from and the data as built by collectFields, and returns an HTTPResponse object that contains the finally formatted data
- collectFields() — Given a fieldspec and a noun, recursively collect the specified fields into a "data" element - a subclass specific object that can then be trivially converted into the expected response.
public
- addCollectionToItem() — Works in concert with #appendToCollection to handle sequences.
- addToItem() — Add a key / value pair to an object as returned by dataItem
- appendToCollection() — Add a value to a sequence
- dataItem() — Given a class as a string, return a "data" item - some object that can hold data during collection
- decodeFields() — Takes a list of fields - a list of "." seperated strings - and turns it into a fieldspec (a nested associative array), where the key is the field, and the value is an array of nested fields or false if no nesting, i.e.
- format() — format is the main public entry point for formatting RESTNouns as output
- get_formatter() — Factory that returns a RESTFormatter subclass that formats in a particular format based on mimetype or extension