You are here

public function LingotekImportForm::import in Lingotek Translation 8

This function is to import a document from the TMS.

@author TJ Murphy

Parameters

string id drupal table doc id, not lingotek document id:

Return value

mixed will return a 0 if there is an error in the conversion, or it will return the $response if there is no error and it converts as expected

1 call to LingotekImportForm::import()
LingotekImportForm::submitForm in src/Form/LingotekImportForm.php
Form submission handler.

File

src/Form/LingotekImportForm.php, line 272
Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Class

LingotekImportForm
@file Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Namespace

Drupal\lingotek\Form

Code

public function import($id) {

  //
  $doc = $this
    ->searchForDoc($id);
  $format = $doc->properties->extension;
  $content = $this
    ->downloadDocumentContent($doc->properties->id);
  if ($content == null) {
    $content == 'There is no content to display';
  }
  $formatConverter = new FormatConverter($doc, $content, $format);
  $importObject = $formatConverter
    ->convert_to_standard();
  if ($importObject
    ->hasError()) {
    return 0;
  }
  $response = $this
    ->import_standard_object($importObject);
  return $response;
}