PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.2
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/Runners/BaseRunner.php +6 -50 3.7.33.1.2 View file →
@@ -6,35 +6,23 @@
6 6 use Templately\Builder\Factory\TemplateFactory;
7 7 use Templately\Core\Importer\FullSiteImport;
8 8 use Templately\Core\Importer\Import;
9 9 use Templately\Core\Importer\LogHelper;
10 -use Templately\Core\Importer\Utils\AIUtils;
11 10 use Templately\Core\Importer\Utils\ImportHelper;
12 11 use Templately\Core\Importer\Utils\Utils;
13 12
14 13 abstract class BaseRunner {
15 14 use LogHelper;
16 - use Loop;
17 15
18 16 const META_SESSION_KEY = '_templately_import_session_id';
19 17 /**
20 18 * @var FullSiteImport
21 19 */
22 - protected $dev_mode;
23 20 protected $origin;
24 21 protected $platform;
25 22 protected $manifest;
26 - protected $prv_dir;
27 23 protected $dir_path;
28 24 protected $session_id;
29 - /**
30 - * @var array|mixed
31 - */
32 - public $ai_page_ids = [];
33 - /**
34 - * @var string|null
35 - */
36 - public $process_id = null;
37 25
38 26 /**
39 27 * @var ImportHelper
40 28 */
@@ -47,30 +35,19 @@
47 35
48 36 /**
49 37 * @throws Exception
50 38 */
51 - public function __construct( $request_params ) {
52 - $this->dev_mode = defined('TEMPLATELY_DEV') && TEMPLATELY_DEV;
53 - $this->origin = $request_params['origin'];
54 - $this->prv_dir = $request_params['prv_dir'];
55 - $this->dir_path = $request_params['dir_path'];
56 - $this->manifest = &$request_params['manifest'];
57 - $this->platform = $this->manifest['platform'] ?? '';
58 - $this->session_id = $request_params['session_id'];
39 + public function __construct( FullSiteImport $full_site_import ) {
40 + $this->origin = $full_site_import;
41 + $this->dir_path = $full_site_import->dir_path;
42 + $this->manifest = &$full_site_import->manifest;
43 + $this->platform = $this->manifest['platform'] ?? '';
44 + $this->session_id = $full_site_import->session_id;
59 45
60 46
61 47 $this->factory = new TemplateFactory( $this->platform );
62 48 $this->json = Utils::get_json_helper( $this->platform );
63 - $this->json->session_id = $this->session_id;
64 49
65 - // Normalize once here so every runner sees the canonical
66 - // `type/sub_type => ['id',...]` shape. This value arrives from the import
67 - // FormData (a JSON string), session data, or the manifest, and consumers
68 - // index into it in ways that either throw or silently miss pages when the
69 - // shape differs. See AIUtils::normalize_ai_page_ids().
70 - $this->ai_page_ids = AIUtils::normalize_ai_page_ids( $request_params['ai_page_ids'] ?? [] );
71 - $this->process_id = $request_params['process_id'] ?? null;
72 -
73 50 if ( empty( $this->platform ) ) {
74 51 throw new Exception( __( 'Platform is not specified. Please try again after specifying the platform.', 'templately' ) );
75 52 }
76 53 }
@@ -106,27 +83,6 @@
106 83 $action = $this->get_action();
107 84 }
108 85
109 86 $this->sse_log( $this->get_name(), $message, min( $progress, 100 ), $action );
110 - }
111 -
112 - /**
113 - * @throws Exception
114 - */
115 - protected function throw($message, $code = 0) {
116 - if ($this->dev_mode) {
117 - error_log(print_r($message, 1));
118 - }
119 - throw new Exception($message);
120 - }
121 -
122 - protected function is_ai_content($old_template_id ): bool {
123 - if(empty($this->process_id) || empty($this->ai_page_ids)){
124 - return false;
125 - }
126 -
127 - // $this->ai_page_ids is already normalized in the constructor, so this is
128 - // a plain flatten + strict membership test. It used to array_reduce with
129 - // 'array_merge', which throws a TypeError if any group value is a scalar.
130 - return AIUtils::is_ai_content($old_template_id, $this->ai_page_ids);
131 87 }
132 88 }