/** * Retrieving all target groups under documents * @param $document * @return array */ public static function getTargetGroups($document) { $document_target_group_mapper = new DocumentTargetGroupDBMapper(); $target_groups = $document_target_group_mapper->getTargetGroupsByDocumentIdAndDocumentTimestamp($document->getId(), $document->getTimestamp()); $target_group_array = []; foreach ($target_groups as $target_group) { array_push($target_group_array, $target_group->toArray()); } return $target_group_array; }
/** * Adds target groups, links and fields to document * @param $document_input * @param $document_id * @return mixed */ private function addContentToDocument($target_groups, $links, $fields, $document_id) { $document = $this->getById($document_id); $document_target_group_db_mapper = new DocumentTargetGroupDBMapper(); $document_link_db_mapper = new LinkDBMapper(); $document_field_db_mapper = new DocumentFieldValueDBMapper(); // Store current document id and timestamp $id = $document->getId(); $timestamp = $document->getTimestamp(); // Add all target groups, links and fields $document_target_group_db_mapper->addMultiple($target_groups, $id, $timestamp); $document_link_db_mapper->addMultiple($links, $id, $timestamp); $document_field_db_mapper->addMultiple($fields, $id, $timestamp); return $document_id; }