SymfonyComponentTranslationDumperCsvFileDumper

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

Defined (1)

The class is defined in the following location(s).

/vendor/symfony/translation/Dumper/CsvFileDumper.php  
  1. class CsvFileDumper extends FileDumper 
  2. private $delimiter = ';'; 
  3. private $enclosure = '"'; 
  4.  
  5. /** 
  6. * {@inheritdoc} 
  7. */ 
  8. public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) 
  9. $handle = fopen('php://memory', 'rb+'); 
  10.  
  11. foreach ($messages->all($domain) as $source => $target) { 
  12. fputcsv($handle, array($source, $target), $this->delimiter, $this->enclosure); 
  13.  
  14. rewind($handle); 
  15. $output = stream_get_contents($handle); 
  16. fclose($handle); 
  17.  
  18. return $output; 
  19.  
  20. /** 
  21. * Sets the delimiter and escape character for CSV. 
  22. * @param string $delimiter delimiter character 
  23. * @param string $enclosure enclosure character 
  24. */ 
  25. public function setCsvControl($delimiter = ';', $enclosure = '"') 
  26. $this->delimiter = $delimiter; 
  27. $this->enclosure = $enclosure; 
  28.  
  29. /** 
  30. * {@inheritdoc} 
  31. */ 
  32. protected function getExtension() 
  33. return 'csv';