chg: [objectReference] Added objectReference/view endpoint

pull/7043/head
mokaddem 2021-02-18 15:42:00 +01:00
parent 5b8a32f851
commit 309db2a37a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 25 additions and 0 deletions

View File

@ -201,5 +201,30 @@ class ObjectReferencesController extends AppController
public function view($id)
{
if (Validation::uuid($id)) {
$temp = $this->ObjectReference->find('first', array(
'recursive' => -1,
'fields' => array('ObjectReference.id'),
'conditions' => array('ObjectReference.uuid' => $id)
));
if (empty($temp)) {
throw new NotFoundException('Invalid object reference');
}
$id = $temp['ObjectReference']['id'];
} elseif (!is_numeric($id)) {
throw new NotFoundException(__('Invalid object reference'));
}
$objectReference = $this->ObjectReference->find('first', array(
'conditions' => array('ObjectReference.id' => $id),
'recursive' => -1,
));
if (empty($objectReference)) {
throw new NotFoundException(__('Invalid object reference.'));
}
$event = $this->ObjectReference->Object->Event->fetchSimpleEvent($this->Auth->user(), $objectReference['ObjectReference']['event_id'], ['contain' => ['Orgc']]);
if (!$event) {
throw new NotFoundException(__('Invalid event'));
}
return $this->RestResponse->viewData($objectReference, 'application/json');
}
}