PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.2.4
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.2.4
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Core/Importer/Import.php +38 -25 3.1.13.2.4 View file →
@@ -2,24 +2,24 @@
2 2
3 3 namespace Templately\Core\Importer;
4 4
5 5 use Exception;
6 +use Templately\Core\Importer\Runners\Attachments;
6 7 use Templately\Core\Importer\Runners\BaseRunner;
7 8 use Templately\Core\Importer\Runners\Customizer;
9 +use Templately\Core\Importer\Runners\Dependencies;
8 10 use Templately\Core\Importer\Runners\ElementorContent;
9 11 use Templately\Core\Importer\Runners\ExtraContent;
10 12 use Templately\Core\Importer\Runners\Finalizer;
11 13 use Templately\Core\Importer\Runners\GutenbergContent;
14 +use Templately\Core\Importer\Runners\Loop;
12 15 use Templately\Core\Importer\Runners\Templates;
13 16 use Templately\Core\Importer\Runners\WPContent;
14 17
15 18 class Import {
16 19 use LogHelper;
20 + use Loop;
17 21
18 - /**
19 - * @var FullSiteImport
20 - */
21 - public $full_site_import;
22 22
23 23 /**
24 24 * @var array
25 25 */
@@ -25,8 +25,10 @@
25 25 */
26 26 private $manifest;
27 27
28 28 private $runners;
29 + private $request_params;
30 + private $session_id;
29 31
30 32 private $imported_data = [];
31 33
32 34 /**
@@ -31,13 +33,13 @@
31 33
32 34 /**
33 35 * @throws Exception
34 36 */
35 - public function __construct( $full_site_import ) {
36 - $this->full_site_import = $full_site_import;
37 + public function __construct( $args ) {
38 + $this->request_params = $args;
39 + $this->manifest = $args['manifest'];
40 + $this->session_id = $args['session_id'];
37 41
38 - $this->manifest = $full_site_import->manifest;
39 -
40 42 $this->register_runners();
41 43 }
42 44
43 45 /**
@@ -45,34 +47,43 @@
45 47 */
46 48 private function register_runners() {
47 49 $this->runners = [
48 50 // TODO: Site Settings Import Runner
49 - new ExtraContent( $this->full_site_import ),
50 - new Templates( $this->full_site_import ),
51 - new GutenbergContent( $this->full_site_import ),
52 - new ElementorContent( $this->full_site_import ),
53 - new WPContent( $this->full_site_import ),
54 - new Customizer( $this->full_site_import ),
55 - new Finalizer( $this->full_site_import )
51 + new Dependencies( $this->request_params ),
52 + new Attachments( $this->request_params ),
53 + new Customizer( $this->request_params ),
54 + new ExtraContent( $this->request_params ),
55 + new Templates( $this->request_params ),
56 + new GutenbergContent( $this->request_params ),
57 + new ElementorContent( $this->request_params ),
58 + new WPContent( $this->request_params ),
59 + new Finalizer( $this->request_params )
56 60 ];
57 61 }
58 62
59 63 public function run( $callable = null ): array {
60 - $data = $this->full_site_import->get_request_params();
64 + $data = $this->request_params;
61 65
66 + // Get the cached imported_data
67 + // $this->imported_data = $data['imported_data'] ?? [];
68 +
62 69 /**
63 70 * @var BaseRunner $runner
64 71 */
65 - foreach ( $this->runners as $runner ) {
72 + $imported_data = $this->loop( $this->runners, function($id, $runner, $imported_data ) use($data) {
73 + $import = [];
74 +
66 75 try{
67 - if ( $runner->should_run( $data, $this->imported_data ) ) {
68 - if( $runner->get_name() != 'finalize' ) {
69 - $runner->log();
76 + if ( $runner->should_run( $data, $imported_data ) ) {
77 + $progress = $this->get_progress();
78 + if(!in_array($runner->get_name(), $progress)){
79 + $runner->log( 0 );
80 + $progress[] = $runner->get_name();
81 + $this->update_progress( $progress);
70 82 }
83 + $import = $runner->import( $data, $imported_data );
84 + $imported_data = array_merge_recursive( $imported_data, $import );
71 85
72 - $import = $runner->import( $data, $this->imported_data );
73 - $this->imported_data = array_merge_recursive( $this->imported_data, $import );
74 -
75 86 if( $runner->get_name() != 'finalize' ) {
76 87 $runner->log( 100 );
77 88 } else {
78 89 $runner->log( 100, $runner->log_message() );
@@ -80,11 +91,13 @@
80 91 }
81 92 }catch (Exception $e){
82 93 error_log($e->getMessage());
83 94 }
84 - }
85 95
86 - return $this->imported_data;
96 + return $imported_data;
97 + }, null, true);
98 +
99 + return $imported_data;
87 100 }
88 101
89 102 public function get_runners() {
90 103 return $this->runners;