Blame view

backend/components/parsers/CustomCsvParser.php 755 Bytes
40ff24a1   Mihail   refactor CsvParse...
1
2
3
4
5
6
7
8
9
10
11
  <?php
  /**
   * Created by PhpStorm.
   * User: Cibermag
   * Date: 04.09.2015
   * Time: 16:07
   */
  
  namespace backend\components\parsers;
  
  
036717a1   Mihail   add error excepti...
12
  class CustomCsvParser extends  \yii\multiparser\CsvParser {
40ff24a1   Mihail   refactor CsvParse...
13
  
474f35bf   Mihail   add DynamicFormHe...
14
15
16
      //public $last_line = 10;
      //public $hasHeaderRow = true;
     // public $keys = ['first','second', 'third', 'forth', 'fifth'];
74072a2a   Mihail   add first version...
17
      public function setupConverter()
40ff24a1   Mihail   refactor CsvParse...
18
19
      {
  
40ff24a1   Mihail   refactor CsvParse...
20
  
74072a2a   Mihail   add first version...
21
22
23
          if ($this->hasHeaderRow) {
              // если у файла есть заголовок, то в результате имеем ассоциативный массив
              $this->converter_conf['hasKey'] = 1;
40ff24a1   Mihail   refactor CsvParse...
24
25
          }
  
74072a2a   Mihail   add first version...
26
27
          $this->converter = \Yii::createObject($this->converter_conf);
           \common\components\CustomVarDamp::dumpAndDie($this);
40ff24a1   Mihail   refactor CsvParse...
28
29
30
  
      }
  
74072a2a   Mihail   add first version...
31
  
40ff24a1   Mihail   refactor CsvParse...
32
  }