PluginProbe
The Innovative Form Builder – IvyForms / 0.8
The Innovative Form Builder – IvyForms v0.8
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 1.2 1.3
ivyforms / backend / src / Entity / Form / Form.php

Form.php in The Innovative Form Builder – IvyForms 0.8, at backend/src/Entity/Form/Form.php

327 lines 7.5 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 namespace IvyForms\Entity\Form;
9
10 // phpcs:disable PSR1.Files.SideEffects
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly
13 }
14
15 use IvyForms\ValueObjects\Form\Form as FormValueObject;
16 use IvyForms\ValueObjects\Form\IntegrationSettings;
17
18 /**
19 * Class Form
20 *
21 * @package IvyForms\Entity\Form
22 */
23 class Form
24 {
25 /**
26 * @var FormValueObject
27 */
28 private FormValueObject $form;
29
30 /**
31 * Form constructor.
32 *
33 * @param FormValueObject $form The form object.
34 */
35 public function __construct(FormValueObject $form)
36 {
37 $this->form = $form;
38 }
39
40 /**
41 * Get the ID of the form.
42 *
43 * @return int The form ID.
44 */
45 public function getId(): int
46 {
47 return $this->form->getId();
48 }
49
50 /**
51 * Set the ID of the form.
52 *
53 * @param int $formId The form ID to set.
54 */
55 public function setId(int $formId): void
56 {
57 $this->form->id = $formId;
58 }
59
60 /**
61 * Get the name of the form.
62 *
63 * @return string The form name.
64 */
65 public function getName(): string
66 {
67 return $this->form->getName();
68 }
69
70 /**
71 * Set the name of the form.
72 *
73 * @param string $name The form name to set.
74 */
75 public function setName(string $name): void
76 {
77 $this->form->name = $name;
78 }
79
80 /**
81 * Get the author of the form.
82 *
83 * @return string The form author.
84 */
85 public function getAuthor(): string
86 {
87 return $this->form->getAuthor();
88 }
89
90 /**
91 * Set the author of the form.
92 *
93 * @param string $author The form author to set.
94 */
95 public function setAuthor(string $author): void
96 {
97 $this->form->author = $author;
98 }
99
100 /**
101 * Get the starred status of the form.
102 *
103 * @return bool The form starred status.
104 */
105 public function isStarred(): bool
106 {
107 return $this->form->isStarred();
108 }
109
110 /**
111 * Set the starred status of the form.
112 *
113 * @param bool $starred The form starred status to set.
114 */
115 public function setStarred(bool $starred): void
116 {
117 $this->form->starred = $starred;
118 }
119
120 /**
121 * Get the published status of the form.
122 *
123 * @return bool The form published status.
124 */
125 public function isPublished(): bool
126 {
127 return $this->form->isPublished();
128 }
129
130 /**
131 * Set the published status of the form.
132 *
133 * @param bool $published The form published status to set.
134 */
135 public function setPublished(bool $published): void
136 {
137 $this->form->published = $published;
138 }
139
140 /**
141 * Get the creation date of the form.
142 *
143 * @return string The form of date creation.
144 */
145 public function getDateCreated(): string
146 {
147 return $this->form->getDateCreated();
148 }
149 /**
150 * Get the date edited of the form.
151 *
152 * @return string The form date edited.
153 */
154 public function getDateEdited(): string
155 {
156 return $this->form->getDateEdited();
157 }
158
159 /**
160 * Get the form fields.
161 *
162 * @return mixed[] The form fields.
163 */
164 public function getFields(): array
165 {
166 return $this->form->getFields();
167 }
168
169 /**
170 * Set the form fields.
171 *
172 * @param mixed[] $fields The form fields to set.
173 */
174 public function setFields(array $fields): void
175 {
176 $this->form->fields = $fields;
177 }
178
179 /**
180 * Get the form description.
181 *
182 * @return string The form description.
183 */
184 public function getDescription(): string
185 {
186 return $this->form->getDescription();
187 }
188
189 /**
190 * Set the form description.
191 *
192 * @param string $description The form description to set.
193 */
194 public function setDescription(string $description): void
195 {
196 $this->form->description = $description;
197 }
198
199 /**
200 * Get the show title of the form.
201 *
202 * @return bool The form show title status.
203 */
204 public function isTitleVisible(): bool
205 {
206 return $this->form->isTitleVisible();
207 }
208
209 /**
210 * Set the show title of the form.
211 *
212 * @param bool $showTitle The form show title to set.
213 */
214 public function setTitleVisible(bool $showTitle): void
215 {
216 $this->form->showTitle = $showTitle;
217 }
218 /**
219 * Get the show description of the form.
220 *
221 * @return bool The form show description status.
222 */
223 public function isDescriptionVisible(): bool
224 {
225 return $this->form->isDescriptionVisible();
226 }
227
228
229 /**
230 * Set the show description of the form.
231 *
232 * @param bool $description The form show title to set.
233 */
234 public function setDescriptionVisible(bool $description): void
235 {
236 $this->form->showDescription = $description;
237 }
238
239 /**
240 *
241 * Set whether to store entries or not.
242 *
243 * @param bool $storeEntries
244 * @return void
245 */
246 public function setStoreEntries(bool $storeEntries): void
247 {
248 $this->form->storeEntries = $storeEntries;
249 }
250 /**
251 *
252 * Get whether to store entries or not.
253 *
254 * @return bool
255 */
256 public function isStoreEntries(): bool
257 {
258 return $this->form->storeEntries;
259 }
260
261 /**
262 * Get integration settings.
263 * @return IntegrationSettings|null The integration settings.
264 */
265 public function getIntegrationSettings(): ?IntegrationSettings
266 {
267 return $this->form->integrationSettings;
268 }
269 /**
270 * Set integration settings.
271 * @param IntegrationSettings|null $settings The integration settings to set.
272 */
273 public function setIntegrationSettings(?IntegrationSettings $settings): void
274 {
275 $this->form->integrationSettings = $settings;
276 }
277
278 /**
279 * Get form action buttons settings.
280 *
281 * @return array<string, mixed> The form action buttons settings.
282 */
283 public function getFormActionButtons(): array
284 {
285 return $this->form->formActionButtons;
286 }
287
288 /**
289 * Set form action buttons settings.
290 *
291 * @param array<string, mixed> $formActionButtons The form action buttons settings to set.
292 * @return void
293 */
294 public function setFormActionButtons(array $formActionButtons): void
295 {
296 $this->form->formActionButtons = $formActionButtons;
297 }
298
299 /**
300 * Convert the form entity to an array.
301 *
302 * @return array<string, mixed> The form entity as an array.
303 */
304 public function toArray(): array
305 {
306 $data = array_merge(
307 [
308 'id' => $this->getId(),
309 'name' => $this->getName(),
310 'author' => $this->getAuthor(),
311 'starred' => $this->isStarred(),
312 'published' => $this->isPublished(),
313 'dateCreated' => $this->getDateCreated(),
314 'dateEdited' => $this->getDateEdited(),
315 'fields' => $this->getFields(),
316 'description' => $this->getDescription(),
317 'showTitle' => $this->isTitleVisible(),
318 'showDescription' => $this->isDescriptionVisible(),
319 'storeEntries' => $this->isStoreEntries(),
320 'formActionButtons' => $this->getFormActionButtons(),
321 ],
322 $this->getIntegrationSettings()->toArray()
323 );
324 return $data;
325 }
326 }
327