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 -19 0.9.1 → 1.5.1 View file →
@@ -6,15 +6,8 @@
6 6 */
7 7
8 8 namespace IvyForms\ValueObjects\Field;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 -use IvyForms\Common\Exceptions\ValidationException;
16 -
17 10 /**
18 11 * Class FieldAdvancedSettings
19 12 *
20 13 * @package IvyForms\ValueObjects\Field
@@ -61,8 +54,13 @@
61 54 */
62 55 private string $ratingIcon;
63 56
64 57 /**
58 + * @var FileUploadFieldAdvancedSettings
59 + */
60 + private FileUploadFieldAdvancedSettings $fileUploadSettings;
61 +
62 + /**
65 63 * FieldAdvancedSettings constructor.
66 64 *
67 65 * @param string $defaultValue
68 66 * @param bool $limitMaxLength
@@ -71,9 +69,9 @@
71 69 * @param bool $noDuplicates
72 70 * @param string $inputPrefix
73 71 * @param string $inputSuffix
74 72 * @param string $ratingIcon
75 - *
73 + * @param FileUploadFieldAdvancedSettings $fileUploadSettings
76 74 */
77 75 public function __construct(
78 76 string $defaultValue,
79 77 bool $limitMaxLength,
@@ -81,9 +79,10 @@
81 79 string $labelPosition,
82 80 bool $noDuplicates,
83 81 string $inputPrefix,
84 82 string $inputSuffix,
85 - string $ratingIcon
83 + string $ratingIcon,
84 + FileUploadFieldAdvancedSettings $fileUploadSettings
86 85 ) {
87 86 $this->defaultValue = $defaultValue;
88 87 $this->limitMaxLength = $limitMaxLength;
89 88 $this->maxLength = $maxLength;
@@ -91,8 +90,9 @@
91 90 $this->noDuplicates = $noDuplicates;
92 91 $this->inputPrefix = $inputPrefix;
93 92 $this->inputSuffix = $inputSuffix;
94 93 $this->ratingIcon = $ratingIcon;
94 + $this->fileUploadSettings = $fileUploadSettings;
95 95 }
96 96
97 97 /**
98 98 * Get the default value.
@@ -253,9 +253,56 @@
253 253 {
254 254 $this->ratingIcon = $ratingIcon;
255 255 }
256 256
257 + public function getFileUploadSettings(): FileUploadFieldAdvancedSettings
258 + {
259 + return $this->fileUploadSettings;
260 + }
261 +
257 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 + /**
258 305 * Convert the advanced settings to an array.
259 306 *
260 307 * @return array<string, mixed>
261 308 */
@@ -260,16 +307,19 @@
260 307 * @return array<string, mixed>
261 308 */
262 309 public function toArray(): array
263 310 {
264 - return [
265 - 'defaultValue' => $this->getDefaultValue(),
266 - 'limitMaxLength' => $this->isLimitMaxLength(),
267 - 'maxLength' => $this->getMaxLength(),
268 - 'labelPosition' => $this->getLabelPosition(),
269 - 'noDuplicates' => $this->isNoDuplicates(),
270 - 'inputPrefix' => $this->getInputPrefix(),
271 - 'inputSuffix' => $this->getInputSuffix(),
272 - 'ratingIcon' => $this->getRatingIcon(),
273 - ];
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 + );
274 324 }
275 325 }