/**
  * Export action
  */
 public function exportAction()
 {
     $request = $this->getRequest();
     $form = $this->getServiceLocator()->get('Form')->get('Grid\\Core\\ListExport');
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $type = $data['type'];
             $options = array_merge((array) (isset($data[$type]) ? $data[$type] : array()), array('fieldNames' => $this->getExportFieldNames()));
             $iterator = $this->getPaginator()->getAdapter()->getItems(0, null);
             $table = new Table($iterator, $this->getExportFieldTypes());
             $response = FileData::fromData($table->export($type, $options), $this->getExportFileName($type));
             $this->getEvent()->setResponse($response);
             return $response;
         }
     }
     $view = new ViewModel(array('form' => $form->setAttribute('action', $request->getRequestUri())));
     return $view->setTemplate('rowSet/export')->setTerminal(true);
 }
Example #2
0
 /**
  * Test empty file
  *
  * @expectedException   RuntimeException
  */
 public function testSetContent()
 {
     $readfile = FileData::fromData($this->fileData);
     $readfile->setContent('foo-bar');
 }