PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
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
← All changes | backend/src/ValueObjects/Field/FieldAdvancedSettings.php +69 -14 1.0 → 1.5.1 View file →
@@ -6,10 +6,8 @@
6 6 */
7 7
8 8 namespace IvyForms\ValueObjects\Field;
9 9
10 -use IvyForms\Common\Exceptions\ValidationException;
11 -
12 10 /**
13 11 * Class FieldAdvancedSettings
14 12 *
15 13 * @package IvyForms\ValueObjects\Field
@@ -56,8 +54,13 @@
56 54 */
57 55 private string $ratingIcon;
58 56
59 57 /**
58 + * @var FileUploadFieldAdvancedSettings
59 + */
60 + private FileUploadFieldAdvancedSettings $fileUploadSettings;
61 +
62 + /**
60 63 * FieldAdvancedSettings constructor.
61 64 *
62 65 * @param string $defaultValue
63 66 * @param bool $limitMaxLength
@@ -66,9 +69,9 @@
66 69 * @param bool $noDuplicates
67 70 * @param string $inputPrefix
68 71 * @param string $inputSuffix
69 72 * @param string $ratingIcon
70 - *
73 + * @param FileUploadFieldAdvancedSettings $fileUploadSettings
71 74 */
72 75 public function __construct(
73 76 string $defaultValue,
74 77 bool $limitMaxLength,
@@ -76,9 +79,10 @@
76 79 string $labelPosition,
77 80 bool $noDuplicates,
78 81 string $inputPrefix,
79 82 string $inputSuffix,
80 - string $ratingIcon
83 + string $ratingIcon,
84 + FileUploadFieldAdvancedSettings $fileUploadSettings
81 85 ) {
82 86 $this->defaultValue = $defaultValue;
83 87 $this->limitMaxLength = $limitMaxLength;
84 88 $this->maxLength = $maxLength;
@@ -86,8 +90,9 @@
86 90 $this->noDuplicates = $noDuplicates;
87 91 $this->inputPrefix = $inputPrefix;
88 92 $this->inputSuffix = $inputSuffix;
89 93 $this->ratingIcon = $ratingIcon;
94 + $this->fileUploadSettings = $fileUploadSettings;
90 95 }
91 96
92 97 /**
93 98 * Get the default value.
@@ -248,9 +253,56 @@
248 253 {
249 254 $this->ratingIcon = $ratingIcon;
250 255 }
251 256
257 + public function getFileUploadSettings(): FileUploadFieldAdvancedSettings
258 + {
259 + return $this->fileUploadSettings;
260 + }
261 +
252 262 /**
263 + * Maximum file size in MB for file-upload fields (0 = server default).
264 + */
265 + public function getMaxFileSizeMb(): int
266 + {
267 + return $this->fileUploadSettings->getMaxFileSizeMb();
268 + }
269 +
270 + public function setMaxFileSizeMb(int $maxFileSizeMb): void
271 + {
272 + $this->fileUploadSettings->setMaxFileSizeMb($maxFileSizeMb);
273 + }
274 +
275 + /**
276 + * Target storage for uploads: ivyforms or media_library.
277 + */
278 + public function getSaveUploadsTo(): string
279 + {
280 + return $this->fileUploadSettings->getSaveUploadsTo();
281 + }
282 +
283 + public function setSaveUploadsTo(string $saveUploadsTo): void
284 + {
285 + $this->fileUploadSettings->setSaveUploadsTo($saveUploadsTo);
286 + }
287 +
288 + /**
289 + * @return array<int, string>
290 + */
291 + public function getAllowedFileExtensions(): array
292 + {
293 + return $this->fileUploadSettings->getAllowedFileExtensions();
294 + }
295 +
296 + /**
297 + * @param array<int, string> $allowedFileExtensions
298 + */
299 + public function setAllowedFileExtensions(array $allowedFileExtensions): void
300 + {
301 + $this->fileUploadSettings->setAllowedFileExtensions($allowedFileExtensions);
302 + }
303 +
304 + /**
253 305 * Convert the advanced settings to an array.
254 306 *
255 307 * @return array<string, mixed>
256 308 */
@@ -255,16 +307,19 @@
255 307 * @return array<string, mixed>
256 308 */
257 309 public function toArray(): array
258 310 {
259 - return [
260 - 'defaultValue' => $this->getDefaultValue(),
261 - 'limitMaxLength' => $this->isLimitMaxLength(),
262 - 'maxLength' => $this->getMaxLength(),
263 - 'labelPosition' => $this->getLabelPosition(),
264 - 'noDuplicates' => $this->isNoDuplicates(),
265 - 'inputPrefix' => $this->getInputPrefix(),
266 - 'inputSuffix' => $this->getInputSuffix(),
267 - 'ratingIcon' => $this->getRatingIcon(),
268 - ];
311 + return array_merge(
312 + [
313 + 'defaultValue' => $this->getDefaultValue(),
314 + 'limitMaxLength' => $this->isLimitMaxLength(),
315 + 'maxLength' => $this->getMaxLength(),
316 + 'labelPosition' => $this->getLabelPosition(),
317 + 'noDuplicates' => $this->isNoDuplicates(),
318 + 'inputPrefix' => $this->getInputPrefix(),
319 + 'inputSuffix' => $this->getInputSuffix(),
320 + 'ratingIcon' => $this->getRatingIcon(),
321 + ],
322 + $this->fileUploadSettings->toArray()
323 + );
269 324 }
270 325 }