/** * 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; }
/** * Retrieving all fields under documents * @param $document * @return array */ public static function getFields($document) { $field_mapper = new DocumentFieldValueDBMapper(); $fields = $field_mapper->getFieldsByDocumentIdAndDocumentTimestamp($document->getId(), $document->getTimestamp()); $field_array = []; foreach ($fields as $field) { array_push($field_array, $field->toArray()); } return $field_array; }