PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / ValueObjects / Form / StyleSettings.php

StyleSettings.php in The Innovative Form Builder – IvyForms 1.0, at backend/src/ValueObjects/Form/StyleSettings.php

61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\ValueObjects\Form;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 use IvyForms\Services\Template\TemplateDefaults;
7
8 if (!defined('ABSPATH')) {
9 exit; // Exit if accessed directly
10 }
11
12 /**
13 * Encapsulates form style settings (quick/advanced mode, themes, classes).
14 *
15 * @property array<string, mixed> $settings
16 */
17 final class StyleSettings
18 {
19 /**
20 * @var array<string, mixed>
21 */
22 private array $settings = [];
23
24 /**
25 * @param array<string, mixed>|null $settings Parsed style settings or null.
26 */
27 public function __construct($settings = null)
28 {
29 $defaults = TemplateDefaults::getDefaultFormStylesSafe();
30
31 if (!is_array($settings) || !array_key_exists('stylesEnabled', $settings)) {
32 $this->settings = $defaults;
33 return;
34 }
35
36 $this->settings = array_replace_recursive($defaults, $settings);
37 }
38
39 /**
40 * Full style settings tree (non-null after construction).
41 *
42 * @return array<string, mixed>
43 */
44 public function getAll(): array
45 {
46 return $this->settings;
47 }
48
49 /**
50 * Export for persistence / array merges (same key as API and DB column).
51 *
52 * @return array{styleSettings: array<string, mixed>}
53 */
54 public function toArray(): array
55 {
56 return [
57 'styleSettings' => $this->settings,
58 ];
59 }
60 }
61