original_string: public function exportFromList($definition = null, $options = [])
      {
          $lists = $this->controller->makeLists();
  
          $widget = $lists[$definition] ?? reset($lists);
  
          /*
           * Parse options
           */
          $defaultOptions = [
              'fileName' => $this->exportFileName,
              'delimiter' => ',',
              'enclosure' => '"'
          ];
  
          $options = array_merge($defaultOptions, $options);
  
          /*
           * Prepare CSV
           */
          $csv = CsvWriter::createFromFileObject(new SplTempFileObject);
          $csv->setDelimiter($options['delimiter']);
          $csv->setEnclosure($options['enclosure']);
  
          /*
           * Add headers
           */
          $headers = [];
          $columns = $widget->getVisibleColumns();
          foreach ($columns as $column) {
              $headers[] = Lang::get($column->label);
          }
          $csv->insertOne($headers);
  
          /*
           * Add records
           */
          $getter = $this->getConfig('export[useList][raw]', false)
              ? 'getColumnValueRaw'
              : 'getColumnValue';
  
          $query = $widget->prepareQuery();
          $results = $query->get();
          foreach ($results as $result) {
              $record = [];
              foreach ($columns as $column) {
                  $value = $widget->$getter($result, $column);
                  if (is_array($value)) {
                      $value = implode('|', $value);
                  }
                  $record[] = $value;
              }
              $csv->insertOne($record);
          }
  
          /*
           * Output
           */
          $csv->output($options['fileName']);
          exit;
      }
code: public function exportFromList($definition = null, $options = [])
      {
          $lists = $this->controller->makeLists();
  
          $widget = $lists[$definition] ?? reset($lists);
  
          /*
           * Parse options
           */
          $defaultOptions = [
              'fileName' => $this->exportFileName,
              'delimiter' => ',',
              'enclosure' => '"'
          ];
  
          $options = array_merge($defaultOptions, $options);
  
          /*
           * Prepare CSV
           */
          $csv = CsvWriter::createFromFileObject(new SplTempFileObject);
          $csv->setDelimiter($options['delimiter']);
          $csv->setEnclosure($options['enclosure']);
  
          /*
           * Add headers
           */
          $headers = [];
          $columns = $widget->getVisibleColumns();
          foreach ($columns as $column) {
              $headers[] = Lang::get($column->label);
          }
          $csv->insertOne($headers);
  
          /*
           * Add records
           */
          $getter = $this->getConfig('export[useList][raw]', false)
              ? 'getColumnValueRaw'
              : 'getColumnValue';
  
          $query = $widget->prepareQuery();
          $results = $query->get();
          foreach ($results as $result) {
              $record = [];
              foreach ($columns as $column) {
                  $value = $widget->$getter($result, $column);
                  if (is_array($value)) {
                      $value = implode('|', $value);
                  }
                  $record[] = $value;
              }
              $csv->insertOne($record);
          }
  
          /*
           * Output
           */
          $csv->output($options['fileName']);
          exit;
      }
code_tokens: public function exportFromList ( $ definition = null , $ options = [ ] ) { $ lists = $ this -> controller -> makeLists ( ) ; $ widget = $ lists [ $ definition ] ?? reset ( $ lists ) ; /*
           * Parse options
           */ $ defaultOptions = [ 'fileName' => $ this -> exportFileName , 'delimiter' => ',' , 'enclosure' => '"' ] ; $ options = array_merge ( $ defaultOptions , $ options ) ; /*
           * Prepare CSV
           */ $ csv = CsvWriter :: createFromFileObject ( new SplTempFileObject ) ; $ csv -> setDelimiter ( $ options [ 'delimiter' ] ) ; $ csv -> setEnclosure ( $ options [ 'enclosure' ] ) ; /*
           * Add headers
           */ $ headers = [ ] ; $ columns = $ widget -> getVisibleColumns ( ) ; foreach ( $ columns as $ column ) { $ headers [ ] = Lang :: get ( $ column -> label ) ; } $ csv -> insertOne ( $ headers ) ; /*
           * Add records
           */ $ getter = $ this -> getConfig ( 'export[useList][raw]' , false ) ? 'getColumnValueRaw' : 'getColumnValue' ; $ query = $ widget -> prepareQuery ( ) ; $ results = $ query -> get ( ) ; foreach ( $ results as $ result ) { $ record = [ ] ; foreach ( $ columns as $ column ) { $ value = $ widget -> $ getter ( $ result , $ column ) ; if ( is_array ( $ value ) ) { $ value = implode ( '|' , $ value ) ; } $ record [ ] = $ value ; } $ csv -> insertOne ( $ record ) ; } /*
           * Output
           */ $ csv -> output ( $ options [ 'fileName' ] ) ; exit ; }
docstring: Outputs the list results as a CSV export.
  @param string $definition
  @param array $options
  @return void
docstring_tokens: Outputs the list results as a CSV export .