Commit 492d8ac1c1ea0e337bff99cd354bfab3f5d5bdaf

Authored by Mihail
1 parent 2a7a75b8

finishing with converter and dynamic form

backend/components/parsers/CustomCsvParser.php
@@ -17,14 +17,12 @@ class CustomCsvParser extends \yii\multiparser\CsvParser { @@ -17,14 +17,12 @@ class CustomCsvParser extends \yii\multiparser\CsvParser {
17 public function setupConverter() 17 public function setupConverter()
18 { 18 {
19 19
20 -  
21 if ($this->hasHeaderRow) { 20 if ($this->hasHeaderRow) {
22 // если у файла есть заголовок, то в результате имеем ассоциативный массив 21 // если у файла есть заголовок, то в результате имеем ассоциативный массив
23 $this->converter_conf['hasKey'] = 1; 22 $this->converter_conf['hasKey'] = 1;
24 } 23 }
25 24
26 $this->converter = \Yii::createObject($this->converter_conf); 25 $this->converter = \Yii::createObject($this->converter_conf);
27 - \common\components\CustomVarDamp::dumpAndDie($this);  
28 26
29 } 27 }
30 28
backend/components/parsers/config.php
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 ,]], 11 ,]],
12 12
13 'basic_column' => [ 13 'basic_column' => [
  14 + Null => 'Пусто',
14 "BRAND" => 'Бренд', 15 "BRAND" => 'Бренд',
15 "ARTICLE"=> 'Артикул', 16 "ARTICLE"=> 'Артикул',
16 "PRICE" => 'Цена', 17 "PRICE" => 'Цена',
backend/controllers/ParserController.php
@@ -120,7 +120,9 @@ public function actionWrite() @@ -120,7 +120,9 @@ public function actionWrite()
120 //CustomVarDamp::dumpAndDie($model); 120 //CustomVarDamp::dumpAndDie($model);
121 if ($model->validate()) { 121 if ($model->validate()) {
122 $arr = $model->toArray(); 122 $arr = $model->toArray();
123 - CustomVarDamp::dumpAndDie($arr); 123 + $data = json_decode( Yii::$app->getCache()->get( 'parser_data' ),true );
  124 +
  125 + CustomVarDamp::dumpAndDie(DynamicFormHelper::CreateAssocArray($data, $arr));
124 } 126 }
125 127
126 128
common/components/CustomVarDamp.php
@@ -17,10 +17,16 @@ class CustomVarDamp extends BaseVarDumper { @@ -17,10 +17,16 @@ class CustomVarDamp extends BaseVarDumper {
17 echo "</pre>"; 17 echo "</pre>";
18 die; 18 die;
19 } 19 }
20 - public static function dump($var, $depth = 10, $highlight = false) 20 + public static function dump($var, $step = '', $depth = 10, $highlight = false)
21 { 21 {
22 echo "<pre>"; 22 echo "<pre>";
  23 + if ($step) {
  24 + echo "-------------- {$step} -------------";
  25 + }
23 echo static::dumpAsString($var, $depth, $highlight); 26 echo static::dumpAsString($var, $depth, $highlight);
  27 + if ($step) {
  28 + echo "-------------- {$step} -------------";
  29 + }
24 echo "</pre>"; 30 echo "</pre>";
25 31
26 } 32 }