cache->get( 'files_to_parse' ) ) { $arr_id_files = json_decode( $arr_id_files ); foreach ( $arr_id_files as $file_name ) { $file_path = Yii::getAlias('@auto_upload') . '/' . $file_name . '.csv'; $config = ['record_id' => $file_name, 'importer_id' => ImportersFiles::findOne(['id' => $file_name])->id, 'parser_config' => ['keys' => ['DESCR', 'ARTICLE', 'BRAND', 'PRICE', 'BOX']] ]; if( $this->parseFileConsole( $file_path, $config ) ){ unlink( $file_path ); if (isset( $arr_id_files[$file_path] ) ) { unset($arr_id_files[$file_path]); } } else { // Yii::$app->log-> // не дошли до конца по этому остаки вернем в кеш Yii::$app->cache->set( 'files_to_parse',json_encode( $arr_id_files ) ); } } if ( !count( $arr_id_files ) ) { Yii::$app->cache->delete( 'files_to_parse' ); } } } public function actionParseXML () { } protected function parseFileConsole( $file_path, $configuration ){ $parser_config = []; if ( isset( $configuration['parser_config'] ) ) { $parser_config = $configuration['parser_config']; } $data = Yii::$app->multiparser->parse( $file_path, $parser_config ); $writer = new PriceWriter(); $writer->configuration = $configuration; $writer->data = $data; $writer->mode = 1; //console-режим if ( $writer->writeDataToDB() ){ Console::output('It is working'); return true; } return false; } }