| @@ -45,14 +45,14 @@ | ||
| 45 | 45 | */ |
| 46 | 46 | private function register_runners() { |
| 47 | 47 | $this->runners = [ |
| 48 | 48 | // TODO: Site Settings Import Runner |
| 49 | - new Customizer( $this->full_site_import ), | |
| 50 | 49 | new ExtraContent( $this->full_site_import ), |
| 51 | 50 | new Templates( $this->full_site_import ), |
| 52 | 51 | new GutenbergContent( $this->full_site_import ), |
| 53 | 52 | new ElementorContent( $this->full_site_import ), |
| 54 | 53 | new WPContent( $this->full_site_import ), |
| 54 | + new Customizer( $this->full_site_import ), | |
| 55 | 55 | new Finalizer( $this->full_site_import ) |
| 56 | 56 | ]; |
| 57 | 57 | } |
| 58 | 58 | |
| @@ -57,24 +57,19 @@ | ||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function run( $callable = null ): array { |
| 60 | 60 | $data = $this->full_site_import->get_request_params(); |
| 61 | - $progress = $this->full_site_import->get_progress(); | |
| 62 | 61 | |
| 63 | - // Get the cached imported_data | |
| 64 | - $this->imported_data = $data['imported_data'] ?? []; | |
| 65 | - | |
| 66 | 62 | /** |
| 67 | 63 | * @var BaseRunner $runner |
| 68 | 64 | */ |
| 69 | - foreach ( $this->runners as $id => $runner ) { | |
| 70 | - $import = null; | |
| 71 | - // If the template has been processed, skip it | |
| 72 | - if (in_array($id, $progress)) { | |
| 73 | - continue; | |
| 74 | - } | |
| 65 | + foreach ( $this->runners as $runner ) { | |
| 75 | 66 | try{ |
| 76 | 67 | if ( $runner->should_run( $data, $this->imported_data ) ) { |
| 68 | + if( $runner->get_name() != 'finalize' ) { | |
| 69 | + $runner->log(); | |
| 70 | + } | |
| 71 | + | |
| 77 | 72 | $import = $runner->import( $data, $this->imported_data ); |
| 78 | 73 | $this->imported_data = array_merge_recursive( $this->imported_data, $import ); |
| 79 | 74 | |
| 80 | 75 | if( $runner->get_name() != 'finalize' ) { |
| @@ -84,25 +79,8 @@ | ||
| 84 | 79 | } |
| 85 | 80 | } |
| 86 | 81 | }catch (Exception $e){ |
| 87 | 82 | error_log($e->getMessage()); |
| 88 | - } | |
| 89 | - | |
| 90 | - // Update the progress | |
| 91 | - $progress[] = $id; | |
| 92 | - $this->full_site_import->update_progress($progress, $import); | |
| 93 | - | |
| 94 | - if(end($this->runners) !== $runner) { | |
| 95 | - // $_runner = $this->runners[$id + 1]; | |
| 96 | - // if($_runner){ | |
| 97 | - // $_runner->log(); | |
| 98 | - // } | |
| 99 | - $this->sse_message( [ | |
| 100 | - 'type' => 'continue', | |
| 101 | - 'action' => 'continue', | |
| 102 | - 'results' => $runner->get_label(), | |
| 103 | - ] ); | |
| 104 | - exit; | |
| 105 | 83 | } |
| 106 | 84 | } |
| 107 | 85 | |
| 108 | 86 | return $this->imported_data; |