1111
1212namespace statikbe \configvaluesfield \fields ;
1313
14- use craft \helpers \App ;
15- use statikbe \configvaluesfield \assetbundles \configvalues \ConfigValuesAsset ;
16- use statikbe \configvaluesfield \ConfigValuesField ;
1714use Craft ;
1815use craft \base \ElementInterface ;
16+ use craft \base \Field ;
1917use craft \base \InlineEditableFieldInterface ;
2018use craft \base \SortableFieldInterface ;
21- use craft \base \Field ;
19+ use craft \helpers \App ;
20+ use statikbe \configvaluesfield \assetbundles \configvalues \ConfigValuesAsset ;
21+ use statikbe \configvaluesfield \ConfigValuesField ;
2222
2323/**
2424 * @author Statik.be
@@ -32,11 +32,11 @@ class ConfigValuesFieldField extends Field implements InlineEditableFieldInterfa
3232 public string $ dataSet = '' ;
3333 public string $ type = 'dropdown ' ;
3434
35- const TYPE_DROPDOWN = 'dropdown ' ;
36- const TYPE_RADIO = 'radios ' ;
37- const TYPE_CHECKBOX = 'checkboxes ' ;
38- const TYPE_COLOR = 'color ' ;
39- const TYPE_SHAPE = 'shape ' ;
35+ public const TYPE_DROPDOWN = 'dropdown ' ;
36+ public const TYPE_RADIO = 'radios ' ;
37+ public const TYPE_CHECKBOX = 'checkboxes ' ;
38+ public const TYPE_COLOR = 'color ' ;
39+ public const TYPE_SHAPE = 'shape ' ;
4040
4141 // Static Methods
4242 // =========================================================================
@@ -71,7 +71,7 @@ public function defineRules(): array
7171 ['dataSet ' , 'required ' ],
7272 ['type ' , 'string ' ],
7373 ['type ' , 'required ' ],
74- ['type ' , 'dataShouldMatchType ' ]
74+ ['type ' , 'dataShouldMatchType ' ],
7575 ]);
7676 return $ rules ;
7777 }
@@ -100,7 +100,7 @@ public function dataShouldMatchType($attribute, $params): void
100100 }
101101 }
102102 } else {
103- if (!in_array ($ option , ['random ' , 'none ' ])) {
103+ if (!in_array ($ option , ['random ' , 'none ' ])) {
104104 $ this ->addError ("$ attribute " , "Each option should either contain a hex value, 'random' or 'none' when type is 'color' " );
105105 return ;
106106 }
@@ -109,26 +109,26 @@ public function dataShouldMatchType($attribute, $params): void
109109 break ;
110110
111111 case self ::TYPE_SHAPE :
112- if (!isset ($ data ['path ' ])) {
112+ if (!isset ($ data ['path ' ])) {
113113 $ this ->addError ("$ attribute " , "A valid path must be configured when type is 'shape' " );
114114 }
115115
116- if (isset ($ data ['path ' ])) {
116+ if (isset ($ data ['path ' ])) {
117117 $ path = App::parseEnv ($ data ['path ' ]);
118- if (!is_dir ($ path )) {
118+ if (!is_dir ($ path )) {
119119 $ this ->addError ("$ attribute " , "The path to the shapes must be a valid directory " );
120120 }
121121 }
122122
123- if (!isset ($ data ['shapes ' ])) {
123+ if (!isset ($ data ['shapes ' ])) {
124124 $ this ->addError ("$ attribute " , "A set of 'shapes' must be configured when type is 'shape' " );
125125 }
126126
127- if (isset ($ data ['shapes ' ]) && isset ($ data ['path ' ])) {
127+ if (isset ($ data ['shapes ' ]) && isset ($ data ['path ' ])) {
128128 $ path = App::parseEnv ($ data ['path ' ]);
129- foreach ($ data ['shapes ' ] as $ filename => $ value ) {
129+ foreach ($ data ['shapes ' ] as $ filename => $ value ) {
130130 $ filepath = $ path . $ filename . '.svg ' ;
131- if (!file_exists ($ filepath )) {
131+ if (!file_exists ($ filepath )) {
132132 $ this ->addError ("$ attribute " , "The file $ filename.svg does not exist in the configured path " );
133133 }
134134 }
0 commit comments