From 492d8ac1c1ea0e337bff99cd354bfab3f5d5bdaf Mon Sep 17 00:00:00 2001 From: Mihail Date: Fri, 11 Sep 2015 14:45:53 +0300 Subject: [PATCH] finishing with converter and dynamic form --- backend/components/parsers/CustomCsvParser.php | 2 -- backend/components/parsers/config.php | 1 + backend/controllers/ParserController.php | 4 +++- common/components/CustomVarDamp.php | 8 +++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/components/parsers/CustomCsvParser.php b/backend/components/parsers/CustomCsvParser.php index 190fd91..55f3153 100644 --- a/backend/components/parsers/CustomCsvParser.php +++ b/backend/components/parsers/CustomCsvParser.php @@ -17,14 +17,12 @@ class CustomCsvParser extends \yii\multiparser\CsvParser { public function setupConverter() { - if ($this->hasHeaderRow) { // если у файла есть заголовок, то в результате имеем ассоциативный массив $this->converter_conf['hasKey'] = 1; } $this->converter = \Yii::createObject($this->converter_conf); - \common\components\CustomVarDamp::dumpAndDie($this); } diff --git a/backend/components/parsers/config.php b/backend/components/parsers/config.php index b98cbfb..a4b5009 100644 --- a/backend/components/parsers/config.php +++ b/backend/components/parsers/config.php @@ -11,6 +11,7 @@ ,]], 'basic_column' => [ + Null => 'Пусто', "BRAND" => 'Бренд', "ARTICLE"=> 'Артикул', "PRICE" => 'Цена', diff --git a/backend/controllers/ParserController.php b/backend/controllers/ParserController.php index 4b86f2a..633d432 100644 --- a/backend/controllers/ParserController.php +++ b/backend/controllers/ParserController.php @@ -120,7 +120,9 @@ public function actionWrite() //CustomVarDamp::dumpAndDie($model); if ($model->validate()) { $arr = $model->toArray(); - CustomVarDamp::dumpAndDie($arr); + $data = json_decode( Yii::$app->getCache()->get( 'parser_data' ),true ); + + CustomVarDamp::dumpAndDie(DynamicFormHelper::CreateAssocArray($data, $arr)); } diff --git a/common/components/CustomVarDamp.php b/common/components/CustomVarDamp.php index adb1aff..4d45831 100644 --- a/common/components/CustomVarDamp.php +++ b/common/components/CustomVarDamp.php @@ -17,10 +17,16 @@ class CustomVarDamp extends BaseVarDumper { echo ""; die; } - public static function dump($var, $depth = 10, $highlight = false) + public static function dump($var, $step = '', $depth = 10, $highlight = false) { echo "
";
+        if ($step) {
+            echo "-------------- {$step} -------------";
+        }
         echo static::dumpAsString($var, $depth, $highlight);
+        if ($step) {
+            echo "-------------- {$step} -------------";
+        }
         echo "
"; } -- libgit2 0.21.4