PluginProbe
Elementor Website Builder – more than just a page builder / trunk
Elementor Website Builder – more than just a page builder vtrunk
4.3.3 4.3.2 4.3.1 4.3.0 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 All 456 releases
elementor / modules / mcp / abilities / appliers / v3 / converter / v3-context-meta.php

v3-context-meta.php in Elementor Website Builder – more than just a page builder trunk, at modules/mcp/abilities/appliers/v3/converter/v3-context-meta.php

69 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Mcp\Abilities\Appliers\V3\Converter;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Immutable per-node conversion metadata: everything a converter needs to look up
11 * the mapping for a rule without recomputing it per declaration.
12 */
13 class V3_Context_Meta {
14
15 private string $widget_type;
16 private array $widget_config;
17 private array $overrides;
18 private array $generic_index;
19
20 public function __construct( string $widget_type, array $widget_config, array $overrides, array $generic_index ) {
21 $this->widget_type = $widget_type;
22 $this->widget_config = $widget_config;
23 $this->overrides = $overrides;
24 $this->generic_index = $generic_index;
25 }
26
27 public function widget_type(): string {
28 return $this->widget_type;
29 }
30
31 public function widget_config(): array {
32 return $this->widget_config;
33 }
34
35 public function overrides(): array {
36 return $this->overrides;
37 }
38
39 public function generic_index(): array {
40 return $this->generic_index;
41 }
42
43 public function controls(): array {
44 $controls = $this->widget_config['controls'] ?? [];
45
46 return is_array( $controls ) ? $controls : [];
47 }
48
49 public function has_control( string $key ): bool {
50 return array_key_exists( $key, $this->controls() );
51 }
52
53 public function match_key( string $property, ?string $state ): string {
54 return null === $state ? $property : $property . '@' . $state;
55 }
56
57 public function get_override( string $property, ?string $state ): ?array {
58 $key = $this->match_key( $property, $state );
59
60 return $this->overrides[ $key ] ?? null;
61 }
62
63 public function get_generic_rule( string $property, ?string $state ): ?array {
64 $key = $this->match_key( $property, $state );
65
66 return $this->generic_index[ $key ] ?? null;
67 }
68 }
69