From 7e55c28c9271d8f02731518dfef1268576250bbc Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Wed, 17 Apr 2019 11:56:35 +0200 Subject: [PATCH] wip: [enrichment] Passing initial object references as well - Also testing if the initial object found is not empty --- app/Controller/EventsController.php | 39 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 5394298e5..45cc11202 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -5143,20 +5143,35 @@ class EventsController extends AppController 'recursive' => -1, 'fields' => array('Object.id', 'Object.uuid', 'Object.name') )); - $initial_attributes = $this->Event->Attribute->find('all', array( - 'conditions' => array('Attribute.object_id' => $object_id, - 'Attribute.deleted' => 0), - 'recursive' => -1, - 'fields' => array('Attribute.id', 'Attribute.uuid', 'Attribute.type', - 'Attribute.object_relation', 'Attribute.value') - )); - if (!empty($initial_attributes)) { - $initial_object['Attribute'] = array(); - foreach ($initial_attributes as $initial_attribute) { - array_push($initial_object['Attribute'], $initial_attribute['Attribute']); + if (!empty($initial_object)) { + $initial_attributes = $this->Event->Attribute->find('all', array( + 'conditions' => array('Attribute.object_id' => $object_id, + 'Attribute.deleted' => 0), + 'recursive' => -1, + 'fields' => array('Attribute.id', 'Attribute.uuid', 'Attribute.type', + 'Attribute.object_relation', 'Attribute.value') + )); + if (!empty($initial_attributes)) { + $initial_object['Attribute'] = array(); + foreach ($initial_attributes as $initial_attribute) { + array_push($initial_object['Attribute'], $initial_attribute['Attribute']); + } } + $initial_references = $this->Event->Object->ObjectReference->find('all', array( + 'conditions' => array('ObjectReference.object_id' => $object_id, + 'ObjectReference.event_id' => $event_id, + 'ObjectReference.deleted' => 0), + 'recursive' => -1, + 'fields' => array('ObjectReference.referenced_uuid', 'ObjectReference.relationship_type') + )); + if (!empty($initial_references)) { + $initial_object['ObjectReference'] = array(); + foreach ($initial_references as $initial_reference) { + array_push($initial_object['ObjectReference'], $initial_reference['ObjectReference']); + } + } + $event['initialObject'] = $initial_object; } - $event['initialObject'] = $initial_object; } $this->set('event', $event); if (!empty($result['results'])) {