fix: [analyst-data:view] Fixed analyst-data/view/all endpoint

notes
Sami Mokaddem 2024-02-16 10:30:26 +01:00
parent 87f4ef1bed
commit 159f5278ef
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 17 additions and 2 deletions

View File

@ -166,7 +166,7 @@ class AnalystDataController extends AppController
{
if ($type === 'all' && Validation::uuid($id)) {
$this->loadModel('AnalystData');
$type = $this->AnalystData->deduceType($id);
$type = $this->AnalystData->getAnalystDataTypeFromUUID($id);
}
$this->__typeSelector($type);
if (!is_numeric($id) && Validation::uuid($id)) {

View File

@ -254,6 +254,21 @@ class AnalystData extends AppModel
throw new NotFoundException(__('Invalid UUID'));
}
public function getAnalystDataTypeFromUUID($uuid)
{
foreach (self::ANALYST_DATA_TYPES as $type) {
$this->{$type} = ClassRegistry::init($type);
$result = $this->{$type}->find('first', [
'conditions' => [$type.'.uuid' => $uuid],
'recursive' => -1
]);
if (!empty($result)) {
return $type;
}
}
throw new NotFoundException(__('Invalid UUID'));
}
public function deduceAnalystDataType(array $analystData)
{
if (!empty($analystData['note_type_name']) && in_array($analystData['note_type_name'], self::ANALYST_DATA_TYPES)) {
@ -269,7 +284,7 @@ class AnalystData extends AppModel
public function getIDFromUUID($type, $id): int
{
$tmpForID = $this->AnalystData->find('first', [
$tmpForID = $this->find('first', [
'conditions' => [
'uuid' => $id,
],