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
← All changes | backend/src/Entity/Form/Form.php +118 -18 1.0 → 1.5 View file →
@@ -6,12 +6,13 @@
6 6 */
7 7
8 8 namespace IvyForms\Entity\Form;
9 9
10 -use IvyForms\Services\Template\TemplateDefaults;
11 10 use IvyForms\ValueObjects\Form\Form as FormValueObject;
12 11 use IvyForms\ValueObjects\Form\IntegrationSettings;
12 +use IvyForms\ValueObjects\Form\PaymentSettings;
13 13 use IvyForms\ValueObjects\Form\StyleSettings;
14 +use IvyForms\Services\Template\TemplateDefaults;
14 15
15 16 /**
16 17 * Class Form
17 18 *
@@ -24,8 +25,15 @@
24 25 */
25 26 private FormValueObject $form;
26 27
27 28 /**
29 + * Top-level extension keys (e.g. Pro settings) for the request lifecycle.
30 + *
31 + * @var array<string, mixed>
32 + */
33 + private array $extensionData = [];
34 +
35 + /**
28 36 * Form constructor.
29 37 *
30 38 * @param FormValueObject $form The form object.
31 39 */
@@ -34,8 +42,24 @@
34 42 $this->form = $form;
35 43 }
36 44
37 45 /**
46 + * @param array<string, mixed> $data
47 + */
48 + public function setExtensionData(array $data): void
49 + {
50 + $this->extensionData = $data;
51 + }
52 +
53 + /**
54 + * @return array<string, mixed>
55 + */
56 + public function getExtensionData(): array
57 + {
58 + return $this->extensionData;
59 + }
60 +
61 + /**
38 62 * Get the ID of the form.
39 63 *
40 64 * @return int The form ID.
41 65 */
@@ -74,8 +98,24 @@
74 98 $this->form->name = $name;
75 99 }
76 100
77 101 /**
102 + * @return string classic|conversational
103 + */
104 + public function getFormType(): string
105 + {
106 + return $this->form->getFormType();
107 + }
108 +
109 + /**
110 + * @param string $formType
111 + */
112 + public function setFormType(string $formType): void
113 + {
114 + $this->form->setFormType($formType);
115 + }
116 +
117 + /**
78 118 * Get the author of the form.
79 119 *
80 120 * @return string The form author.
81 121 */
@@ -80,9 +120,9 @@
80 120 * @return string The form author.
81 121 */
82 122 public function getAuthor(): string
83 123 {
84 - return $this->form->getAuthor();
124 + return $this->form->metadata->getAuthor();
85 125 }
86 126
87 127 /**
88 128 * Set the author of the form.
@@ -90,9 +130,9 @@
90 130 * @param string $author The form author to set.
91 131 */
92 132 public function setAuthor(string $author): void
93 133 {
94 - $this->form->author = $author;
134 + $this->form->metadata->author = $author;
95 135 }
96 136
97 137 /**
98 138 * Get the starred status of the form.
@@ -100,9 +140,9 @@
100 140 * @return bool The form starred status.
101 141 */
102 142 public function isStarred(): bool
103 143 {
104 - return $this->form->isStarred();
144 + return $this->form->metadata->isStarred();
105 145 }
106 146
107 147 /**
108 148 * Set the starred status of the form.
@@ -110,9 +150,9 @@
110 150 * @param bool $starred The form starred status to set.
111 151 */
112 152 public function setStarred(bool $starred): void
113 153 {
114 - $this->form->starred = $starred;
154 + $this->form->metadata->starred = $starred;
115 155 }
116 156
117 157 /**
118 158 * Get the published status of the form.
@@ -120,9 +160,9 @@
120 160 * @return bool The form published status.
121 161 */
122 162 public function isPublished(): bool
123 163 {
124 - return $this->form->isPublished();
164 + return $this->form->metadata->isPublished();
125 165 }
126 166
127 167 /**
128 168 * Set the published status of the form.
@@ -130,9 +170,9 @@
130 170 * @param bool $published The form published status to set.
131 171 */
132 172 public function setPublished(bool $published): void
133 173 {
134 - $this->form->published = $published;
174 + $this->form->metadata->published = $published;
135 175 }
136 176
137 177 /**
138 178 * Get the creation date of the form.
@@ -140,9 +180,9 @@
140 180 * @return string The form of date creation.
141 181 */
142 182 public function getDateCreated(): string
143 183 {
144 - return $this->form->getDateCreated();
184 + return $this->form->metadata->getDateCreated();
145 185 }
146 186 /**
147 187 * Get the date edited of the form.
148 188 *
@@ -149,9 +189,9 @@
149 189 * @return string The form date edited.
150 190 */
151 191 public function getDateEdited(): string
152 192 {
153 - return $this->form->getDateEdited();
193 + return $this->form->metadata->getDateEdited();
154 194 }
155 195
156 196 /**
157 197 * Get the form fields.
@@ -199,9 +239,9 @@
199 239 * @return bool The form show title status.
200 240 */
201 241 public function isTitleVisible(): bool
202 242 {
203 - return $this->form->isTitleVisible();
243 + return $this->form->settings->isShowTitle();
204 244 }
205 245
206 246 /**
207 247 * Set the show title of the form.
@@ -209,9 +249,9 @@
209 249 * @param bool $showTitle The form show title to set.
210 250 */
211 251 public function setTitleVisible(bool $showTitle): void
212 252 {
213 - $this->form->showTitle = $showTitle;
253 + $this->form->settings->showTitle = $showTitle;
214 254 }
215 255 /**
216 256 * Get the show description of the form.
217 257 *
@@ -218,9 +258,9 @@
218 258 * @return bool The form show description status.
219 259 */
220 260 public function isDescriptionVisible(): bool
221 261 {
222 - return $this->form->isDescriptionVisible();
262 + return $this->form->settings->isShowDescription();
223 263 }
224 264 /**
225 265 * Set the show description of the form.
226 266 *
@@ -227,13 +267,12 @@
227 267 * @param bool $description The form show title to set.
228 268 */
229 269 public function setDescriptionVisible(bool $description): void
230 270 {
231 - $this->form->showDescription = $description;
271 + $this->form->settings->showDescription = $description;
232 272 }
233 273
234 274 /**
235 - *
236 275 * Set whether to store entries or not.
237 276 *
238 277 * @param bool $storeEntries
239 278 * @return void
@@ -239,9 +278,9 @@
239 278 * @return void
240 279 */
241 280 public function setStoreEntries(bool $storeEntries): void
242 281 {
243 - $this->form->storeEntries = $storeEntries;
282 + $this->form->settings->storeEntries = $storeEntries;
244 283 }
245 284 /**
246 285 *
247 286 * Get whether to store entries or not.
@@ -249,9 +288,9 @@
249 288 * @return bool
250 289 */
251 290 public function isStoreEntries(): bool
252 291 {
253 - return $this->form->storeEntries;
292 + return $this->form->settings->isStoreEntries();
254 293 }
255 294
256 295 /**
257 296 * Get integration settings.
@@ -270,8 +309,44 @@
270 309 $this->form->integrationSettings = $settings;
271 310 }
272 311
273 312 /**
313 + * Get pages.
314 + * @return array<int, array<string, mixed>> The pages array.
315 + */
316 + public function getPages(): array
317 + {
318 + return $this->form->pages ?? [];
319 + }
320 +
321 + /**
322 + * Set pages.
323 + * @param array<int, array<string, mixed>> $pages The pages array to set.
324 + */
325 + public function setPages(array $pages): void
326 + {
327 + $this->form->pages = $pages;
328 + }
329 +
330 + /**
331 + * Get progress indicator settings.
332 + * @return array<string, mixed> The progress indicator settings.
333 + */
334 + public function getProgressIndicator(): array
335 + {
336 + return $this->form->progressIndicator ?? [];
337 + }
338 +
339 + /**
340 + * Set progress indicator settings.
341 + * @param array<string, mixed> $progressIndicator The progress indicator settings to set.
342 + */
343 + public function setProgressIndicator(array $progressIndicator): void
344 + {
345 + $this->form->progressIndicator = $progressIndicator;
346 + }
347 +
348 + /**
274 349 * Get form action buttons settings.
275 350 *
276 351 * @return array<string, mixed> The form action buttons settings.
277 352 */
@@ -291,8 +366,24 @@
291 366 $this->form->formActionButtons = $formActionButtons;
292 367 }
293 368
294 369 /**
370 + * Get payment-related form settings (e.g., currency).
371 + */
372 + public function getPaymentSettings(): PaymentSettings
373 + {
374 + return $this->form->getPaymentSettings();
375 + }
376 +
377 + /**
378 + * Set payment-related form settings.
379 + */
380 + public function setPaymentSettings(PaymentSettings $paymentSettings): void
381 + {
382 + $this->form->setPaymentSettings($paymentSettings);
383 + }
384 +
385 + /**
295 386 * Get style settings as array
296 387 *
297 388 * @return array<string, mixed>
298 389 */
@@ -330,9 +421,9 @@
330 421 $integrationPayload = $integrationSettings !== null
331 422 ? $integrationSettings->toArray()
332 423 : ['integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings()];
333 424
334 - return array_merge(
425 + $data = array_merge(
335 426 [
336 427 'id' => $this->getId(),
337 428 'name' => $this->getName(),
338 429 'author' => $this->getAuthor(),
@@ -341,14 +432,23 @@
341 432 'dateCreated' => $this->getDateCreated(),
342 433 'dateEdited' => $this->getDateEdited(),
343 434 'fields' => $this->getFields(),
344 435 'description' => $this->getDescription(),
436 + 'formType' => $this->getFormType(),
345 437 'showTitle' => $this->isTitleVisible(),
346 438 'showDescription' => $this->isDescriptionVisible(),
347 439 'storeEntries' => $this->isStoreEntries(),
440 + 'pages' => $this->getPages(),
441 + 'progressIndicator' => $this->getProgressIndicator(),
348 442 'styleSettings' => $this->getStyleSettings(),
349 443 'formActionButtons' => $this->getFormActionButtons(),
350 444 ],
351 - $integrationPayload
445 + $this->form->metadata->toArray(),
446 + $this->form->settings->toArray(),
447 + $integrationPayload,
448 + $this->extensionData,
449 + $this->getPaymentSettings()->toArray()
352 450 );
451 +
452 + return $data;
353 453 }
354 454 }