You are here

private function ChartsApiExample::getCsvContents in Charts 5.0.x

Return value

array $all_rows

1 call to ChartsApiExample::getCsvContents()
ChartsApiExample::display in modules/charts_api_example/src/Controller/ChartsApiExample.php
Display the dashboard of charts.

File

modules/charts_api_example/src/Controller/ChartsApiExample.php, line 304

Class

ChartsApiExample
Charts Api Example.

Namespace

Drupal\charts_api_example\Controller

Code

private function getCsvContents() {
  $file_path = drupal_get_path('module', 'charts_api_example');
  $file_name = $file_path . '/fixtures/charts_api_example_file.csv';
  $handle = fopen($file_name, 'r');
  $all_rows = [];
  while ($row = fgetcsv($handle)) {
    $all_rows['Week'][] = $row[0];
    $all_rows['7.x-2.x'][] = (int) $row[4];
    $all_rows['8.x-3.x'][] = (int) $row[6];
    $all_rows['5.0.x'][] = (int) $row[8];
  }
  fclose($handle);
  return $all_rows;
}