You are here

public function Exporter::getData in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/Exporter.php \AKlump\LoftDataGrids\Exporter::getData()

Return the ExportDataInterface object

Return value

ExportDataInterface

Overrides ExporterInterface::getData

1 call to Exporter::getData()
Exporter::formatColumn in vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/Exporter.php
Format a single column with format by string

File

vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/Exporter.php, line 99

Class

Exporter
Class Exporter

Namespace

AKlump\LoftDataGrids

Code

public function getData() {

  // @todo I feel like this is a really bloated way of doing this
  // by creating a new object, etc.  Maybe we can do this differntly...
  // We pause our locations so that our iterations don't mess with things,
  // we'll later resume below.
  $this->export_data
    ->storeLocation('getData');
  $locations = $this->export_data
    ->getLocations();

  // Sort the data into the correct order based on the header
  $pages = $this->export_data
    ->get();
  $temp = new ExportData();
  foreach ($pages as $page_id => $data) {
    $temp
      ->setPage($page_id);
    $header = $this
      ->getHeader($page_id);
    foreach ($data as $d) {
      foreach (array_keys($header) as $key) {
        $temp
          ->add($key, $d[$key]);
      }
      $temp
        ->next();
    }
  }
  $this
    ->setData($temp);
  $this->export_data
    ->setLocations($locations);
  $this->export_data
    ->gotoLocation('getData');
  return $this->export_data;
}