You are here

public function Xml::export in TMGMT Translator Smartling 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/tmgmt_file/Format/Xml.php \Drupal\tmgmt_smartling\Plugin\tmgmt_file\Format\Xml::export()
  2. 8.2 src/Plugin/tmgmt_file/Format/Xml.php \Drupal\tmgmt_smartling\Plugin\tmgmt_file\Format\Xml::export()
  3. 8.3 src/Plugin/tmgmt_file/Format/Xml.php \Drupal\tmgmt_smartling\Plugin\tmgmt_file\Format\Xml::export()

.

Overrides Html::export

File

src/Plugin/tmgmt_file/Format/Xml.php, line 22

Class

Xml
Export into HTML.

Namespace

Drupal\tmgmt_smartling\Plugin\tmgmt_file\Format

Code

public function export(JobInterface $job, $conditions = []) {

  // Export job items data without relation to their ids.
  $items = [];
  foreach ($job
    ->getItems($conditions) as $item) {
    $data = \Drupal::service('tmgmt.data')
      ->filterTranslatable($item
      ->getData());
    foreach ($data as $key => $value) {

      // TODO: identical filename task.
      // $items[$item->id()][$this->encodeIdSafeBase64($item->getItemType() . ':' . $item->getItemId() . '][' . $key)] = $value;
      $items[$item
        ->id()][$this
        ->encodeIdSafeBase64($item
        ->id() . '][' . $key)] = $value;
    }
  }
  $elements = [
    '#theme' => 'tmgmt_smartling_xml_template',
    '#items' => $items,
  ];
  return \Drupal::service('renderer')
    ->renderPlain($elements);
}