PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / app / modules / import-export-customization / design-system-import-context.php

design-system-import-context.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at app/modules/import-export-customization/design-system-import-context.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\ImportExportCustomization;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Shared import context for design-system entities (global classes, global variables).
11 * Resolves the import flow ('settings' vs 'design-system') and its conflict resolution strategy.
12 */
13 class Design_System_Import_Context {
14 /**
15 * Either 'settings', 'design-system' or null.
16 *
17 * @var string|null
18 */
19 private ?string $include_key;
20
21 private function __construct( ?string $include_key ) {
22 $this->include_key = $include_key;
23 }
24
25 public static function from_data( array $data ): self {
26 $include = $data['include'] ?? [];
27
28 if ( in_array( 'settings', $include, true ) ) {
29 return new self( 'settings' );
30 }
31
32 if ( in_array( 'design-system', $include, true ) ) {
33 return new self( 'design-system' );
34 }
35
36 return new self( null );
37 }
38
39 public function is_included(): bool {
40 return null !== $this->include_key;
41 }
42
43 public function is_settings(): bool {
44 return 'settings' === $this->include_key;
45 }
46
47 public function is_design_system(): bool {
48 return 'design-system' === $this->include_key;
49 }
50
51 public function resolve_conflict_resolution( array $data, string $override_all_key ): string {
52 if ( $this->is_settings() ) {
53 return ! empty( $data['customization']['settings'][ $override_all_key ] )
54 ? 'override-all'
55 : 'merge';
56 }
57
58 if ( $this->is_design_system() ) {
59 return $data['customization']['design-system']['conflict_resolution'] ?? 'skip';
60 }
61
62 throw new \Exception( 'Cannot resolve conflict resolution without a valid include include_key.' );
63 }
64 }
65