← All changes
|
modules/atomic-widgets/prop-dependencies/manager.php
+3
-26
4.2.2
→
3.32.0-dev3
View file →
| @@ -35,10 +35,8 @@ | ||
| 35 | 35 | * terms: array{ |
| 36 | 36 | * operator: string, |
| 37 | 37 | * path: array<string>, |
| 38 | 38 | * value?: mixed, |
| 39 | - * newValue?: array, | |
| 40 | - * effect?: 'hide'|'disable' | |
| 41 | 39 | * } |
| 42 | 40 | * } |
| 43 | 41 | */ |
| 44 | 42 | private ?array $dependencies; |
| @@ -71,30 +69,12 @@ | ||
| 71 | 69 | * @param $config array{ |
| 72 | 70 | * operator: string, |
| 73 | 71 | * path: array<string>, |
| 74 | 72 | * value?: mixed, |
| 75 | - * newValue?: array, | |
| 76 | - * effect?: 'hide'|'disable' | |
| 77 | 73 | * } |
| 78 | 74 | * @return self |
| 79 | 75 | */ |
| 80 | - public function where( array $config, $new_value = null ): self { | |
| 81 | - if ( isset( $config['terms'] ) ) { | |
| 82 | - if ( empty( $this->dependencies ) ) { | |
| 83 | - $this->new(); | |
| 84 | - } | |
| 85 | - | |
| 86 | - $term = [ | |
| 87 | - 'terms' => $config['terms'], | |
| 88 | - 'relation' => $config['relation'] ?? self::RELATION_OR, | |
| 89 | - 'newValue' => $new_value ?? null, | |
| 90 | - 'effect' => $config['effect'] ?? 'disable', | |
| 91 | - ]; | |
| 92 | - $this->dependencies['terms'][] = $term; | |
| 93 | - | |
| 94 | - return $this; | |
| 95 | - } | |
| 96 | - | |
| 76 | + public function where( array $config ): self { | |
| 97 | 77 | if ( ! isset( $config['operator'] ) || ! isset( $config['path'] ) ) { |
| 98 | 78 | Utils::safe_throw( 'Term missing mandatory configurations' ); |
| 99 | 79 | } |
| 100 | 80 | |
| @@ -104,12 +84,9 @@ | ||
| 104 | 84 | |
| 105 | 85 | $term = [ |
| 106 | 86 | 'operator' => $config['operator'], |
| 107 | 87 | 'path' => $config['path'], |
| 108 | - 'nestedPath' => $config['nestedPath'] ?? null, | |
| 109 | 88 | 'value' => $config['value'] ?? null, |
| 110 | - 'newValue' => $config['newValue'] ?? null, | |
| 111 | - 'effect' => $config['effect'] ?? 'disable', | |
| 112 | 89 | ]; |
| 113 | 90 | |
| 114 | 91 | if ( empty( $this->dependencies ) ) { |
| 115 | 92 | $this->new(); |
| @@ -137,10 +114,10 @@ | ||
| 137 | 114 | return empty( $this->dependencies['terms'] ?? [] ) ? null : $this->dependencies; |
| 138 | 115 | } |
| 139 | 116 | |
| 140 | 117 | /** |
| 141 | - * @param array<string, Prop_Type> $props_schema The props schema to analyze, where keys are prop names | |
| 142 | - * @param ?array<string> $current_path The current property path being processed | |
| 118 | + * @param array<string, Prop_Type> $props_schema The props schema to analyze, where keys are prop names | |
| 119 | + * @param ?array<string> $current_path The current property path being processed | |
| 143 | 120 | * @param ?array<string, array<string>> $dependency_graph The dependency graph to build |
| 144 | 121 | */ |
| 145 | 122 | private static function build_dependency_graph( array $props_schema, ?array $current_path = [], ?array $dependency_graph = [] ): array { |
| 146 | 123 | foreach ( $props_schema as $prop_name => $prop_type ) { |