You are here

public function CSVExporter::compile in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/CSVExporter.php \AKlump\LoftDataGrids\CSVExporter::compile()

Build $this->output in prep for export/save

This is the main method to be extended for the different exporters

Overrides Exporter::compile

2 methods override CSVExporter::compile()
FlatTextExporter::compile in vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/FlatTextExporter.php
Build $this->output in prep for export/save
HTMLExporter::compile in vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/HTMLExporter.php
Build $this->output in prep for export/save

File

vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/CSVExporter.php, line 38

Class

CSVExporter
Class CSVExporter

Namespace

AKlump\LoftDataGrids

Code

public function compile($page_id = NULL) {
  $pages = $this
    ->getData()
    ->get();
  if ($page_id === NULL && count($pages) > 1 || !array_key_exists($page_id, $pages)) {
    reset($pages);
    $page_id = key($pages);
  }
  $data = $this
    ->getData()
    ->getPage($page_id);
  $this->output = '';
  $this->output .= $this
    ->collapseRow($this
    ->getHeader($page_id));

  // Format the rows:
  foreach ($data as $row) {
    $this->output .= $this
      ->collapseRow($row);
  }
}