public function EntityShareServerRestAbstract::handle in Entity Share 7
Handle the server.
File
- modules/
entity_share_server/ includes/ entity_share_server.rest.abstract.inc, line 155 - Class for handling Entity Share Rest Server request.
Class
- EntityShareServerRestAbstract
- Abstract Class to manage the EntityShare Rest server.
Code
public function handle() {
try {
// Security.
if (!$this
->isRequestAllowed()) {
$this
->setHeader('Status', '403 Forbidden');
$this
->sendHeaders();
return;
}
switch ($this
->getParam('type')) {
case 'login':
switch ($this
->getRequestMethod()) {
case 'POST':
// Manage login.
$this
->doLogin();
break;
default:
$this
->setError('HTTP Method not managed');
}
break;
default:
// HTTP_METHOD.
switch ($this
->getRequestMethod()) {
case 'GET':
// Read an entity.
$this
->handleGet();
break;
case 'POST':
// Create a new entity.
$this
->handlePost();
break;
case 'PUT':
// Update an entity.
$this
->handlePut();
break;
case 'DELETE':
// Delete an entity.
$this
->handleDelete();
break;
default:
$this
->setError('HTTP Method not managed');
}
}
} catch (Exception $e) {
$this
->setError('Internal error', '500 Internal Server Error');
}
$this
->outputResponse();
}