| @@ -11,29 +11,18 @@ | ||
| 11 | 11 | use Templately\Core\Importer\Utils\Utils; |
| 12 | 12 | |
| 13 | 13 | abstract class BaseRunner { |
| 14 | 14 | use LogHelper; |
| 15 | - use Loop; | |
| 16 | 15 | |
| 17 | 16 | const META_SESSION_KEY = '_templately_import_session_id'; |
| 18 | 17 | /** |
| 19 | 18 | * @var FullSiteImport |
| 20 | 19 | */ |
| 21 | - protected $dev_mode; | |
| 22 | 20 | protected $origin; |
| 23 | 21 | protected $platform; |
| 24 | 22 | protected $manifest; |
| 25 | - protected $prv_dir; | |
| 26 | 23 | protected $dir_path; |
| 27 | 24 | protected $session_id; |
| 28 | - /** | |
| 29 | - * @var array|mixed | |
| 30 | - */ | |
| 31 | - public $ai_page_ids = []; | |
| 32 | - /** | |
| 33 | - * @var string|null | |
| 34 | - */ | |
| 35 | - public $process_id = null; | |
| 36 | 25 | |
| 37 | 26 | /** |
| 38 | 27 | * @var ImportHelper |
| 39 | 28 | */ |
| @@ -46,25 +35,19 @@ | ||
| 46 | 35 | |
| 47 | 36 | /** |
| 48 | 37 | * @throws Exception |
| 49 | 38 | */ |
| 50 | - public function __construct( $request_params ) { | |
| 51 | - $this->dev_mode = defined('TEMPLATELY_DEV') && TEMPLATELY_DEV; | |
| 52 | - $this->origin = $request_params['origin']; | |
| 53 | - $this->prv_dir = $request_params['prv_dir']; | |
| 54 | - $this->dir_path = $request_params['dir_path']; | |
| 55 | - $this->manifest = &$request_params['manifest']; | |
| 56 | - $this->platform = $this->manifest['platform'] ?? ''; | |
| 57 | - $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; | |
| 58 | 45 | |
| 59 | 46 | |
| 60 | 47 | $this->factory = new TemplateFactory( $this->platform ); |
| 61 | 48 | $this->json = Utils::get_json_helper( $this->platform ); |
| 62 | - $this->json->session_id = $this->session_id; | |
| 63 | 49 | |
| 64 | - $this->ai_page_ids = $request_params['ai_page_ids'] ?? []; | |
| 65 | - $this->process_id = $request_params['process_id'] ?? null; | |
| 66 | - | |
| 67 | 50 | if ( empty( $this->platform ) ) { |
| 68 | 51 | throw new Exception( __( 'Platform is not specified. Please try again after specifying the platform.', 'templately' ) ); |
| 69 | 52 | } |
| 70 | 53 | } |
| @@ -100,31 +83,6 @@ | ||
| 100 | 83 | $action = $this->get_action(); |
| 101 | 84 | } |
| 102 | 85 | |
| 103 | 86 | $this->sse_log( $this->get_name(), $message, min( $progress, 100 ), $action ); |
| 104 | - } | |
| 105 | - | |
| 106 | - /** | |
| 107 | - * @throws Exception | |
| 108 | - */ | |
| 109 | - protected function throw($message, $code = 0) { | |
| 110 | - if ($this->dev_mode) { | |
| 111 | - error_log(print_r($message, 1)); | |
| 112 | - } | |
| 113 | - throw new Exception($message); | |
| 114 | - } | |
| 115 | - | |
| 116 | - protected function is_ai_content($old_template_id ): bool { | |
| 117 | - if(empty($this->process_id) || empty($this->ai_page_ids) || !is_array($this->ai_page_ids)){ | |
| 118 | - return false; | |
| 119 | - } | |
| 120 | - // Get array of AI page IDs, filtering out any non-numeric values | |
| 121 | - $ai_page_ids = array_reduce($this->ai_page_ids, 'array_merge', array()); | |
| 122 | - // $ai_page_ids = array_filter( | |
| 123 | - // array_map('intval', explode(',', $this->ai_page_ids ?? '')) | |
| 124 | - // ); | |
| 125 | - | |
| 126 | - $is_ai_content = in_array($old_template_id, $ai_page_ids); | |
| 127 | - | |
| 128 | - return $is_ai_content; | |
| 129 | 87 | } |
| 130 | 88 | } |