示例#1
0
 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;
 }