示例#1
0
文件: Exporter.php 项目: jekv/devia
 /**
  * Export controller
  *
  * @param $type
  * @param $data
  */
 public function export($type, $criteria = 'all')
 {
     switch ($type) {
         case 'xls':
             $this->exporter = new \SimpleSubscribe\ExporterExcel('browser', $this->fileName . '.xls');
             $this->exporter->addRow($this->columnHeaders);
             foreach ($this->subscribers->getByCriteria($criteria) as $subscriber) {
                 $this->exporter->addRow(array_values($subscriber));
             }
             break;
         case 'csv':
             $this->exporter = new \SimpleSubscribe\ExporterCSV('browser', $this->fileName . '.csv');
             $this->exporter->addRow($this->columnHeaders);
             foreach ($this->subscribers->getByCriteria($criteria) as $subscriber) {
                 $this->exporter->addRow(array_values($subscriber));
             }
             break;
         case 'tsv':
             $this->exporter = new \SimpleSubscribe\ExporterTSV('browser', $this->fileName . '.tsv');
             $this->exporter->addRow($this->columnHeaders);
             foreach ($this->subscribers->getByCriteria($criteria) as $subscriber) {
                 $this->exporter->addRow(array_values($subscriber));
             }
             break;
         case 'xml':
             $this->exporter = new \SimpleSubscribe\ExporterXML($this->fileName . '.xml');
             foreach ($this->subscribers->getByCriteria($criteria) as $subscriber) {
                 $this->exporter->addRow($subscriber);
             }
             break;
     }
 }