PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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 / Field / FileUploadFieldAdvancedSettings.php

FileUploadFieldAdvancedSettings.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/ValueObjects/Field/FileUploadFieldAdvancedSettings.php

95 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 declare(strict_types=1);
9
10 namespace IvyForms\ValueObjects\Field;
11
12 /**
13 * File-upload-specific advanced field settings.
14 */
15 final class FileUploadFieldAdvancedSettings
16 {
17 /**
18 * Max upload size per file (MB). 0 uses server maximum.
19 */
20 private int $maxFileSizeMb;
21
22 /**
23 * Where uploads are stored: ivyforms (uploads dir) or media_library.
24 */
25 private string $saveUploadsTo;
26
27 /**
28 * Allowed extensions without dot (e.g. png, jpg). Empty = all types.
29 *
30 * @var array<int, string>
31 */
32 private array $allowedFileExtensions;
33
34 /**
35 * @param array<int, string> $allowedFileExtensions
36 */
37 public function __construct(
38 int $maxFileSizeMb = 0,
39 string $saveUploadsTo = 'ivyforms',
40 array $allowedFileExtensions = []
41 ) {
42 $this->maxFileSizeMb = $maxFileSizeMb;
43 $this->saveUploadsTo = $saveUploadsTo;
44 $this->allowedFileExtensions = $allowedFileExtensions;
45 }
46
47 public function getMaxFileSizeMb(): int
48 {
49 return $this->maxFileSizeMb;
50 }
51
52 public function setMaxFileSizeMb(int $maxFileSizeMb): void
53 {
54 $this->maxFileSizeMb = $maxFileSizeMb;
55 }
56
57 public function getSaveUploadsTo(): string
58 {
59 return $this->saveUploadsTo;
60 }
61
62 public function setSaveUploadsTo(string $saveUploadsTo): void
63 {
64 $this->saveUploadsTo = $saveUploadsTo;
65 }
66
67 /**
68 * @return array<int, string>
69 */
70 public function getAllowedFileExtensions(): array
71 {
72 return $this->allowedFileExtensions;
73 }
74
75 /**
76 * @param array<int, string> $allowedFileExtensions
77 */
78 public function setAllowedFileExtensions(array $allowedFileExtensions): void
79 {
80 $this->allowedFileExtensions = $allowedFileExtensions;
81 }
82
83 /**
84 * @return array<string, int|string|array<int, string>>
85 */
86 public function toArray(): array
87 {
88 return [
89 'maxFileSizeMb' => $this->getMaxFileSizeMb(),
90 'saveUploadsTo' => $this->getSaveUploadsTo(),
91 'allowedFileExtensions' => $this->getAllowedFileExtensions(),
92 ];
93 }
94 }
95