You are here

public function CsvEncoder::setSettings in CSV Serialization 8

Same name and namespace in other branches
  1. 8.2 src/Encoder/CsvEncoder.php \Drupal\csv_serialization\Encoder\CsvEncoder::setSettings()

Set CSV settings from the Views settings array.

If a tab character ('\t') is used for the delimiter, it will be properly converted to "\t".

1 call to CsvEncoder::setSettings()
CsvEncoder::encode in src/Encoder/CsvEncoder.php
Uses HTML-safe strings, with several characters escaped.

File

src/Encoder/CsvEncoder.php, line 359

Class

CsvEncoder
Adds CSV encoder support for the Serialization API.

Namespace

Drupal\csv_serialization\Encoder

Code

public function setSettings(array $settings) {

  // Replace tab character with one that will be properly interpreted.
  $this->delimiter = str_replace('\\t', "\t", $settings['delimiter']);
  $this->enclosure = $settings['enclosure'];
  $this->escapeChar = $settings['escape_char'];
  $this->useUtf8Bom = $settings['encoding'] === 'utf8' && !empty($settings['utf8_bom']);
  $this->stripTags = $settings['strip_tags'];
  $this->trimValues = $settings['trim'];
  if (array_key_exists('output_header', $settings)) {
    $this->outputHeader = $settings['output_header'];
  }
}