1 | <?php |
||
7 | class ResolveConfig |
||
8 | { |
||
9 | /** |
||
10 | * Validates and resolves a configuration for a local field group. |
||
11 | * |
||
12 | * @param array $config Configuration array for the local field group. |
||
13 | * |
||
14 | * @return array Resolved field group configuration. |
||
15 | */ |
||
16 | public static function forFieldGroup($config) |
||
29 | |||
30 | /** |
||
31 | * Validates a location the configuration for a field group location. |
||
32 | * |
||
33 | * @param array $config Configuration array for a location of a field group. |
||
34 | * |
||
35 | * @return array Valid config. |
||
36 | */ |
||
37 | public static function forLocation($config) |
||
41 | |||
42 | /** |
||
43 | * Validates and resolves a field configuration. |
||
44 | * |
||
45 | * @param array $config Configuration array for a any kind of field. |
||
46 | * @param array $parentKeys Previously used keys of all parent fields. |
||
47 | * |
||
48 | * @return array Resolved config for a field. |
||
49 | */ |
||
50 | public static function forField($config, $parentKeys = []) |
||
54 | |||
55 | /** |
||
56 | * Validates and resolves a layout configuration of a flexible content field. |
||
57 | * |
||
58 | * @param array $config Configuration array for the local field group. |
||
59 | * @param array $parentKeys Previously used keys of all parent fields. |
||
60 | * |
||
61 | * @return array Resolved config for a layout of a flexible content field. |
||
62 | */ |
||
63 | public static function forLayout($config, $parentKeys = []) |
||
67 | |||
68 | |||
69 | /** |
||
70 | * Validates and resolves configuration for a field, subfield, or layout. Applies prefix through filter arguments. |
||
71 | * |
||
72 | * @param array $config Configuration array for the nested entity. |
||
73 | * @param array $requiredAttributes Required attributes. |
||
74 | * @param array $parentKeys Previously used keys of all parent fields. |
||
75 | * @param string $prefix Optional prefix for named field based on filter arguments. |
||
76 | * |
||
77 | * @return array Resolved config. |
||
78 | */ |
||
79 | protected static function forEntity($config, $requiredAttributes, $parentKeys = [], $prefix = null) |
||
127 | |||
128 | /** |
||
129 | * Validates and resolves configuration for subfields and layouts. |
||
130 | * |
||
131 | * @param array $config Configuration array for the nested entity. |
||
132 | * @param array $parentKeys Previously used keys of all parent fields. |
||
133 | * |
||
134 | * @return array Resolved config. |
||
135 | */ |
||
136 | protected static function forNestedEntities($config, $parentKeys) |
||
166 | |||
167 | /** |
||
168 | * Validates a configuration array based on given required attributes. |
||
169 | * |
||
170 | * Usually the field key has to be provided for conditional logic to work. Since all keys are generated automatically by this plugin, you can instead provide a 'relative path' to a field by it's name. |
||
171 | * |
||
172 | * @param array $config Configuration array. |
||
173 | * @param array $requiredAttributes Required Attributes. |
||
174 | * |
||
175 | * @throws Exception if a required attribute is not present. |
||
176 | * @throws Exception if the `key` attribute is not present. |
||
177 | * |
||
178 | * @return array Given $config. |
||
179 | */ |
||
180 | protected static function validateConfig($config, $requiredAttributes = []) |
||
192 | |||
193 | /** |
||
194 | * Maps location configurations to their resolved config arrays. |
||
195 | * |
||
196 | * @param array $locationArray All locations for a field group. |
||
197 | * |
||
198 | * @return array Resolved locations array. |
||
199 | */ |
||
200 | protected static function mapLocation($locationArray) |
||
204 | |||
205 | /** |
||
206 | * Resolves a field's conditional logic attribute. |
||
207 | * |
||
208 | * Usually the field key has to be provided for conditional logic to work. Since all keys are generated automatically by this plugin, you can instead provide a 'relative path' to a field by it's name. |
||
209 | * |
||
210 | * @param array $config Configuration array for the conditional logic attribute. |
||
211 | * @param array $parentKeys Previously used keys of all parent fields. |
||
212 | * |
||
213 | * @return array Resolved conditional logic attribute. |
||
214 | */ |
||
215 | protected static function forConditionalLogic($config, $parentKeys) |
||
237 | |||
238 | /** |
||
239 | * Checks whether or not a given array is associative. |
||
240 | * |
||
241 | * @param array $arr Array to check. |
||
242 | * |
||
243 | * @return boolean |
||
244 | */ |
||
245 | protected static function isAssoc(array $arr) |
||
252 | |||
253 | /** |
||
254 | * Adds a single or multiple elements to an array. |
||
255 | * |
||
256 | * @param array &$arr Array to add to. |
||
257 | * @param array $fields Single or multiple associative arrays to add to $arr. |
||
258 | * |
||
259 | * @return boolean |
||
260 | */ |
||
261 | protected static function pushSingleOrMultiple(array &$carry, array $fields) |
||
272 | } |
||
273 |