| @@ -2,10 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Templately\Core\Importer; |
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | -use Templately\Core\Importer\Exception\NonRetirableErrorException; | |
| 7 | -use Templately\Core\Importer\Runners\AIContent; | |
| 8 | 6 | use Templately\Core\Importer\Runners\Attachments; |
| 9 | 7 | use Templately\Core\Importer\Runners\BaseRunner; |
| 10 | 8 | use Templately\Core\Importer\Runners\Customizer; |
| 11 | 9 | use Templately\Core\Importer\Runners\Dependencies; |
| @@ -57,13 +55,10 @@ | ||
| 57 | 55 | new Templates( $this->request_params ), |
| 58 | 56 | new GutenbergContent( $this->request_params ), |
| 59 | 57 | new ElementorContent( $this->request_params ), |
| 60 | 58 | new WPContent( $this->request_params ), |
| 61 | - // new AIContent( $this->request_params ), | |
| 62 | 59 | new Finalizer( $this->request_params ) |
| 63 | 60 | ]; |
| 64 | - | |
| 65 | - $this->runners = apply_filters( 'templately_import_runners', $this->runners, $this->request_params ); | |
| 66 | 61 | } |
| 67 | 62 | |
| 68 | 63 | public function run( $callable = null ): array { |
| 69 | 64 | $data = $this->request_params; |
| @@ -78,14 +73,16 @@ | ||
| 78 | 73 | $import = []; |
| 79 | 74 | |
| 80 | 75 | try{ |
| 81 | 76 | if ( $runner->should_run( $data, $imported_data ) ) { |
| 82 | - if (!$this->is_key_processed($runner->get_name(), 'runner_start')) { | |
| 77 | + $progress = $this->get_progress(); | |
| 78 | + if(!in_array($runner->get_name(), $progress)){ | |
| 83 | 79 | $runner->log( 0 ); |
| 84 | - $this->mark_key_processed($runner->get_name(), 'runner_start'); | |
| 80 | + $progress[] = $runner->get_name(); | |
| 81 | + $this->update_progress( $progress); | |
| 85 | 82 | } |
| 86 | 83 | $import = $runner->import( $data, $imported_data ); |
| 87 | - $imported_data = array_merge( $imported_data, $import ); | |
| 84 | + $imported_data = array_merge_recursive( $imported_data, $import ); | |
| 88 | 85 | |
| 89 | 86 | if( $runner->get_name() != 'finalize' ) { |
| 90 | 87 | $runner->log( 100 ); |
| 91 | 88 | } else { |
| @@ -93,13 +90,8 @@ | ||
| 93 | 90 | } |
| 94 | 91 | } |
| 95 | 92 | }catch (Exception $e){ |
| 96 | 93 | error_log($e->getMessage()); |
| 97 | - | |
| 98 | - // Re-throw NonRetirableErrorException to stop the import process | |
| 99 | - if ($e instanceof NonRetirableErrorException) { | |
| 100 | - throw $e; | |
| 101 | - } | |
| 102 | 94 | } |
| 103 | 95 | |
| 104 | 96 | return $imported_data; |
| 105 | 97 | }, null, true); |
| @@ -109,5 +101,5 @@ | ||
| 109 | 101 | |
| 110 | 102 | public function get_runners() { |
| 111 | 103 | return $this->runners; |
| 112 | 104 | } |
| 113 | -} | |
| 105 | +} | |