new: [sightings:view] Added endpoint sightings/view to get sightings by ID or UUID

pull/9370/head
Sami Mokaddem 2023-11-07 15:16:39 +01:00
parent abdca8808d
commit e83295ef35
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 17 additions and 0 deletions

View File

@ -119,6 +119,23 @@ class SightingsController extends AppController
}
}
public function view($idOrUUID)
{
$sighting = $this->Sighting->find('first', array(
'conditions' => Validation::uuid($idOrUUID) ? ['Sighting.uuid' => $idOrUUID] : ['Sighting.id' => $idOrUUID],
'recursive' => -1,
'fields' => ['id', 'attribute_id'],
));
$sightings = [];
if (!empty($sighting)) {
$sightings = $this->Sighting->listSightings($this->Auth->user(), $sighting['Sighting']['attribute_id'], 'attribute');
}
if (empty($sightings)) {
throw new NotFoundException('Invalid sighting.');
}
return $this->RestResponse->viewData($sightings[0]);
}
public function advanced($id, $context = 'attribute')
{
if (empty($id)) {