Framework
3.9
|
APIHelper is a class designed to simplify the sharing of data between applications. More...
Public Member Functions | |
__construct ($class, $searchFilter=null, $outputFilter=null, $constraints="") | |
Creates an APIHelper for the specified class. More... | |
query () | |
Process an API query. More... | |
registerFormat ($name, $formatter) | |
Register a format and its associated formatter. More... | |
Public Attributes | |
$class | |
$constraints | |
$searchFilter | |
$outputFilter | |
$format = "json" | |
$formatterMap = array() | |
APIHelper is a class designed to simplify the sharing of data between applications.
It allows you to very quickly implement a RESTful web service that queries a given DataItem class and return the results in many different formats. Output formatting is extensible, but by default supports JSON, XML (in the canonical Fakoli format), Excel and CSV for all objects.
You can provide search and output filters to be applied to your queries, as well as standard constraints as need. Finally, you can easily provide templated output rendering using the easy-to-use template formatter, and full custom output rendering by implementing your own APIFormatter.
Definition at line 232 of file api_helper.inc.
APIHelper::__construct | ( | $class, | |
$searchFilter = null , |
|||
$outputFilter = null , |
|||
$constraints = "" |
|||
) |
Creates an APIHelper for the specified class.
string | $class | the class name for the DataItem class |
Filter | $searchFilter | (optional) InclusionFilter or ExclusionFilter limiting the search fields |
Filter | $outputFilter | (optional) InclusionFilter or ExclusionFilter limiting the output fields |
string | $constraints | (optional) standard SQL constraint to apply to all queries |
Definition at line 248 of file api_helper.inc.
APIHelper::query | ( | ) |
Process an API query.
FakoliException |
Definition at line 266 of file api_helper.inc.
APIHelper::registerFormat | ( | $name, | |
$formatter | |||
) |
Register a format and its associated formatter.
string | $name | the name of the format. |
APIFormatter | $formatter | the formatter object that will handle requests in this format. |
Definition at line 296 of file api_helper.inc.
APIHelper::$class |
Definition at line 234 of file api_helper.inc.
APIHelper::$constraints |
Definition at line 235 of file api_helper.inc.
APIHelper::$format = "json" |
Definition at line 238 of file api_helper.inc.
APIHelper::$formatterMap = array() |
Definition at line 239 of file api_helper.inc.
APIHelper::$outputFilter |
Definition at line 237 of file api_helper.inc.
APIHelper::$searchFilter |
Definition at line 236 of file api_helper.inc.