{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Publish Item",
"description": "",
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id" : {
"type": "string"
},
"title" : {
"type": "string"
},
"description" : {
"type": "string"
},
"required": ["id", "title", "description"]
}
},
"minItems": 1,
"uniqueItems": true
}
},
"required": ["data"]
}
{ "data" : [
{
"id" : "9140555314413871701",
"title": "Name",
"description" : "<b>Item Description</b>"
},
{
"id" : "9140555314413871805",
"title": "Name 2",
"description" : "<b>Item Description 2</b>"
}
]
}
<?php
/**
* Found at: Controllers/Box.php
*
* Handle requests to [URL]/Controllers/Box. Automagically handles CRUD (GET/POST/PUT/DELETE) for the xPDOObject class myBox.
*/
class myControllersBox extends modRestController {
public $classKey = 'myBox';
public $defaultSortField = 'name';
public $defaultSortDirection = 'DESC';
/**
* Handle DELETE requests
* @return array
*/
public function delete() {
// override the delete action in here...
// otherwise...
return parent::delete();
}
/**
* Handles updating of objects
* @return array
*/
public function put() {
// override the put action in here...
// otherwise...
return parent::put();
}
/**
* Method for routing POST requests. Can be overridden; default behavior automates xPDOObject, class-based requests.
* @abstract
*/
public function post() {
// override the post action in here...
// otherwise...
return parent::post();
}
/**
* Abstract method for routing GET requests without a primary key passed. Must be defined in your derivative
* controller. Handles fetching of collections of objects.
*
* @abstract
* @return array
*/
public function getList() {
// override the getList action in here...
// otherwise...
return parent::getList();
}
/**
* Output a collection of objects as a list.
*
* @param array $list
* @param int|boolean $total
* @param int $status
*/
public function collection($list = array(), $total = false, $status = null) {
// override the collection output fron getList action above in here...
// otherwise...
return parent::collection($list, $total, $status);
}
/**
* Abstract method for routing GET requests with a primary key passed. Must be defined in your derivative
* controller.
* @abstract
* @param $id
*/
public function read($id) {
// override the read action in here...
// otherwise...
return parent::read($id);
}
}
<?php
class myParentController extends modRestController {
// all the overriding classes above are here...
}
<?php
/**
* Found at: Controllers/Box.php
*
* Handle requests to [URL]/Controllers/Box. Automagically handles CRUD (GET/POST/PUT/DELETE) for the xPDOObject class myBox.
*/
include_once 'path/to/myParentController.php';
class myControllersBox extends myParentController {
// define the classKey in here
public $classKey = 'myBox';
public $defaultSortField = 'name';
public $defaultSortDirection = 'DESC';
// nothing in here, except you have specific overriding algorithm for the particular $classKey for any particular method
}