You are here

class CsvFileDumper in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/Dumper/CsvFileDumper.php \Symfony\Component\Translation\Dumper\CsvFileDumper

CsvFileDumper generates a csv formatted string representation of a message catalogue.

@author Stealth35

Hierarchy

Expanded class hierarchy of CsvFileDumper

1 file declares its use of CsvFileDumper
CsvFileDumperTest.php in vendor/symfony/translation/Tests/Dumper/CsvFileDumperTest.php

File

vendor/symfony/translation/Dumper/CsvFileDumper.php, line 21

Namespace

Symfony\Component\Translation\Dumper
View source
class CsvFileDumper extends FileDumper {
  private $delimiter = ';';
  private $enclosure = '"';

  /**
   * {@inheritdoc}
   */
  public function format(MessageCatalogue $messages, $domain = 'messages') {
    $handle = fopen('php://memory', 'rb+');
    foreach ($messages
      ->all($domain) as $source => $target) {
      fputcsv($handle, array(
        $source,
        $target,
      ), $this->delimiter, $this->enclosure);
    }
    rewind($handle);
    $output = stream_get_contents($handle);
    fclose($handle);
    return $output;
  }

  /**
   * Sets the delimiter and escape character for CSV.
   *
   * @param string $delimiter delimiter character
   * @param string $enclosure enclosure character
   */
  public function setCsvControl($delimiter = ';', $enclosure = '"') {
    $this->delimiter = $delimiter;
    $this->enclosure = $enclosure;
  }

  /**
   * {@inheritdoc}
   */
  protected function getExtension() {
    return 'csv';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CsvFileDumper::$delimiter private property
CsvFileDumper::$enclosure private property
CsvFileDumper::format public function Transforms a domain of a message catalogue to its string representation. Overrides FileDumper::format
CsvFileDumper::getExtension protected function Gets the file extension of the dumper. Overrides FileDumper::getExtension
CsvFileDumper::setCsvControl public function Sets the delimiter and escape character for CSV.
FileDumper::$backup private property Make file backup before the dump.
FileDumper::$relativePathTemplate protected property A template for the relative paths to files. 1
FileDumper::dump public function Dumps the message catalogue. Overrides DumperInterface::dump 1
FileDumper::getRelativePath private function Gets the relative file path using the template.
FileDumper::setBackup public function Sets backup flag.
FileDumper::setRelativePathTemplate public function Sets the template for the relative paths to files.