protected function EntityShareServerRest::handlePost in Entity Share 7
Handle the POST method action.
Create a new entity.
Overrides EntityShareServerRestAbstract::handlePost
1 call to EntityShareServerRest::handlePost()
- EntityShareServerRest::handlePut in modules/
entity_share_server/ includes/ entity_share_server.rest.inc - Handle the PUT method action.
File
- modules/
entity_share_server/ includes/ entity_share_server.rest.inc, line 56 - Class for handling REST request.
Class
- EntityShareServerRest
- Class EntityShareServerRest.
Code
protected function handlePost() {
$request = $this
->getRequest();
if (isset($request)) {
$entity = $request['datas'];
try {
$import = new EntityShareEntityImport($entity);
$entity_id = $import
->execute();
if (!empty($entity_id)) {
$this
->setResult(array(
'entity_id' => $entity_id,
));
}
else {
$this
->setError('Entity not created');
}
} catch (Exception $e) {
$this
->setError('Error will trying to create entity', '500 Internal Server Error');
}
}
}