You are here

public function Html::export in Translation Management Tool 8

Implements TMGMTFileExportInterface::export().

Overrides FormatInterface::export

File

translators/tmgmt_file/src/Plugin/tmgmt_file/Format/Html.php, line 41

Class

Html
Export into HTML.

Namespace

Drupal\tmgmt_file\Plugin\tmgmt_file\Format

Code

public function export(JobInterface $job, $conditions = array()) {
  $items = array();
  foreach ($job
    ->getItems($conditions) as $item) {
    $data = \Drupal::service('tmgmt.data')
      ->filterTranslatable($item
      ->getData());
    foreach ($data as $key => $value) {
      $items[$item
        ->id()][$this
        ->encodeIdSafeBase64($item
        ->id() . '][' . $key)] = $value;
    }
  }
  $elements = array(
    '#theme' => 'tmgmt_file_html_template',
    '#tjid' => $job
      ->id(),
    '#source_language' => $job
      ->getRemoteSourceLanguage(),
    '#target_language' => $job
      ->getRemoteTargetLanguage(),
    '#items' => $items,
  );
  return \Drupal::service('renderer')
    ->renderPlain($elements);
}