public function add($autodate = true, $null_values = false) { $textMasterAPI = TextMasterAPI::getInstance(); $result = $textMasterAPI->addProject($this->api_data); if (is_array($result)) { //$this->documents_api = $result['documents']; $this->id_project_api = $result['id']; } else { return $result; } // error if (!parent::add($autodate, $null_values)) { return false; } $this->id = Db::getInstance()->Insert_ID(); return true; }
public function add($send_to_api = true, $null_values = false) { if ($send_to_api) { $textMasterAPI = new TextMasterAPI(); $result = $textMasterAPI->addDocument($this->id_project_api, $this->api_data); if (is_array($result)) { $id_document_api = $result['id']; foreach ($this->api_data['original_content'] as $element => $text) { $textMasterDocument = new TextMasterDocument(); $textMasterDocument->name = $element; $textMasterDocument->id_product = (int) $this->api_data['id_product']; $textMasterDocument->id_project = $this->id_project; $textMasterDocument->id_document_api = $id_document_api; if (!$textMasterDocument->add(false)) { return false; } } } else { return $result; } // error } else { return parent::add(true, false); } return true; }