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