← All changes
|
backend/src/ValueObjects/Field/FieldGeneralSettings.php
+176
-9
0.5
→
1.5
View file →
| @@ -1,21 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * @copyright © TMS-Plugins. All rights reserved. | |
| 4 | + * @copyright © Melograno Venture Studio. All rights reserved. | |
| 5 | 5 | * @licence See LICENCE.md for license details. |
| 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 | - | |
| 16 | 10 | use IvyForms\Common\Exceptions\ValidationException; |
| 11 | +use IvyForms\ValueObjects\Field\ConfirmationGeneralSettings; | |
| 17 | 12 | use IvyForms\ValueObjects\Field\TimeFieldGeneralSettings; |
| 13 | +use IvyForms\ValueObjects\Field\DateFieldGeneralSettings; | |
| 18 | 14 | |
| 19 | 15 | /** |
| 20 | 16 | * Class FieldGeneralSettings |
| 21 | 17 | * |
| @@ -92,16 +88,47 @@ | ||
| 92 | 88 | * @var float Step increment for number fields |
| 93 | 89 | */ |
| 94 | 90 | public float $step; |
| 95 | 91 | /** |
| 92 | + * @var bool Show grid marks on slider | |
| 93 | + */ | |
| 94 | + public bool $showGrid; | |
| 95 | + /** | |
| 96 | 96 | * @var string Number format key |
| 97 | 97 | */ |
| 98 | 98 | public string $numberFormat; |
| 99 | 99 | /** |
| 100 | + * Confirmation settings grouped in a dedicated value object. | |
| 101 | + * @var ConfirmationGeneralSettings | |
| 102 | + */ | |
| 103 | + private ConfirmationGeneralSettings $confirmationSettings; | |
| 104 | + /** | |
| 100 | 105 | * Time settings grouped in a dedicated value object. |
| 101 | 106 | * @var TimeFieldGeneralSettings |
| 102 | 107 | */ |
| 103 | 108 | private TimeFieldGeneralSettings $timeSettings; |
| 109 | + /** | |
| 110 | + * Date settings grouped in a dedicated value object. | |
| 111 | + * @var DateFieldGeneralSettings | |
| 112 | + */ | |
| 113 | + private DateFieldGeneralSettings $dateSettings; | |
| 114 | + /** | |
| 115 | + * Whether to show text labels alongside rating. | |
| 116 | + * @var bool | |
| 117 | + */ | |
| 118 | + private bool $showRatingText; | |
| 119 | + /** | |
| 120 | + * @var string HTML content for HTML field type | |
| 121 | + */ | |
| 122 | + private string $htmlContent; | |
| 123 | + /** | |
| 124 | + * @var string Agreement text for GDPR field type | |
| 125 | + */ | |
| 126 | + private string $agreementText; | |
| 127 | + /** | |
| 128 | + * @var bool | |
| 129 | + */ | |
| 130 | + private bool $limitRange; | |
| 104 | 131 | |
| 105 | 132 | /** |
| 106 | 133 | * Public constructor |
| 107 | 134 | * |
| @@ -120,11 +147,17 @@ | ||
| 120 | 147 | * @param bool $phoneAutoDetect |
| 121 | 148 | * @param float|null $minValue |
| 122 | 149 | * @param float|null $maxValue |
| 123 | 150 | * @param float $step |
| 151 | + * @param bool $showGrid | |
| 124 | 152 | * @param string $numberFormat |
| 153 | + * @param ConfirmationGeneralSettings $confirmationSettings | |
| 125 | 154 | * @param TimeFieldGeneralSettings $timeSettings |
| 155 | + * @param DateFieldGeneralSettings $dateSettings | |
| 126 | 156 | * @param bool $visible |
| 157 | + * @param bool $showRatingText | |
| 158 | + * @param string $htmlContent | |
| 159 | + * @param bool $limitRange | |
| 127 | 160 | */ |
| 128 | 161 | /** |
| 129 | 162 | * @SuppressWarnings("ExcessiveParameterList") |
| 130 | 163 | * @SuppressWarnings("BooleanArgumentFlag") |
| @@ -145,11 +178,18 @@ | ||
| 145 | 178 | bool $phoneAutoDetect, |
| 146 | 179 | ?float $minValue, |
| 147 | 180 | ?float $maxValue, |
| 148 | 181 | float $step, |
| 182 | + bool $showGrid, | |
| 149 | 183 | string $numberFormat, |
| 184 | + ConfirmationGeneralSettings $confirmationSettings, | |
| 150 | 185 | TimeFieldGeneralSettings $timeSettings, |
| 151 | - bool $visible = true | |
| 186 | + DateFieldGeneralSettings $dateSettings, | |
| 187 | + bool $showRatingText, | |
| 188 | + bool $visible = true, | |
| 189 | + string $htmlContent = '', | |
| 190 | + string $agreementText = '', | |
| 191 | + bool $limitRange = false | |
| 152 | 192 | ) { |
| 153 | 193 | $this->label = $label; |
| 154 | 194 | $this->required = $required; |
| 155 | 195 | $this->placeholder = $placeholder; |
| @@ -165,11 +205,18 @@ | ||
| 165 | 205 | $this->phoneAutoDetect = $phoneAutoDetect; |
| 166 | 206 | $this->minValue = $minValue; |
| 167 | 207 | $this->maxValue = $maxValue; |
| 168 | 208 | $this->step = $step; |
| 209 | + $this->showGrid = $showGrid; | |
| 169 | 210 | $this->numberFormat = $numberFormat; |
| 170 | 211 | $this->visible = $visible; |
| 212 | + $this->confirmationSettings = $confirmationSettings; | |
| 171 | 213 | $this->timeSettings = $timeSettings; |
| 214 | + $this->dateSettings = $dateSettings; | |
| 215 | + $this->htmlContent = $htmlContent; | |
| 216 | + $this->showRatingText = $showRatingText; | |
| 217 | + $this->agreementText = $agreementText; | |
| 218 | + $this->limitRange = $limitRange; | |
| 172 | 219 | } |
| 173 | 220 | |
| 174 | 221 | /** |
| 175 | 222 | * Get the label. |
| @@ -279,8 +326,17 @@ | ||
| 279 | 326 | return $this->visible; |
| 280 | 327 | } |
| 281 | 328 | |
| 282 | 329 | /** |
| 330 | + * Accessor for confirmation settings value object. | |
| 331 | + * @return ConfirmationGeneralSettings | |
| 332 | + */ | |
| 333 | + public function getConfirmationSettings(): ConfirmationGeneralSettings | |
| 334 | + { | |
| 335 | + return $this->confirmationSettings; | |
| 336 | + } | |
| 337 | + | |
| 338 | + /** | |
| 283 | 339 | * Accessor for time settings value object. |
| 284 | 340 | * @return TimeFieldGeneralSettings |
| 285 | 341 | */ |
| 286 | 342 | public function getTimeSettings(): TimeFieldGeneralSettings |
| @@ -288,8 +344,17 @@ | ||
| 288 | 344 | return $this->timeSettings; |
| 289 | 345 | } |
| 290 | 346 | |
| 291 | 347 | /** |
| 348 | + * Accessor for date settings value object. | |
| 349 | + * @return DateFieldGeneralSettings | |
| 350 | + */ | |
| 351 | + public function getDateSettings(): DateFieldGeneralSettings | |
| 352 | + { | |
| 353 | + return $this->dateSettings; | |
| 354 | + } | |
| 355 | + | |
| 356 | + /** | |
| 292 | 357 | * Get the phone format. |
| 293 | 358 | * |
| 294 | 359 | * @return string |
| 295 | 360 | */ |
| @@ -387,8 +452,28 @@ | ||
| 387 | 452 | $this->step = $step; |
| 388 | 453 | } |
| 389 | 454 | |
| 390 | 455 | /** |
| 456 | + * Get the show grid value. | |
| 457 | + * | |
| 458 | + * @return bool | |
| 459 | + */ | |
| 460 | + public function getShowGrid(): bool | |
| 461 | + { | |
| 462 | + return $this->showGrid; | |
| 463 | + } | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * Set the show grid value. | |
| 467 | + * | |
| 468 | + * @param bool $showGrid | |
| 469 | + */ | |
| 470 | + public function setShowGrid(bool $showGrid): void | |
| 471 | + { | |
| 472 | + $this->showGrid = $showGrid; | |
| 473 | + } | |
| 474 | + | |
| 475 | + /** | |
| 391 | 476 | * Get the number format. |
| 392 | 477 | * |
| 393 | 478 | * @return string |
| 394 | 479 | */ |
| @@ -407,8 +492,83 @@ | ||
| 407 | 492 | $this->numberFormat = $numberFormat; |
| 408 | 493 | } |
| 409 | 494 | |
| 410 | 495 | /** |
| 496 | + * Get the HTML content. | |
| 497 | + * @return string | |
| 498 | + */ | |
| 499 | + public function getHtmlContent(): string | |
| 500 | + { | |
| 501 | + return $this->htmlContent; | |
| 502 | + } | |
| 503 | + | |
| 504 | + /** | |
| 505 | + * Set the HTML content. | |
| 506 | + * | |
| 507 | + * @param string $htmlContent | |
| 508 | + */ | |
| 509 | + public function setHtmlContent(string $htmlContent): void | |
| 510 | + { | |
| 511 | + $this->htmlContent = $htmlContent; | |
| 512 | + } | |
| 513 | + | |
| 514 | + /** | |
| 515 | + * Get showRatingText flag. | |
| 516 | + * @return bool | |
| 517 | + */ | |
| 518 | + public function isShowRatingText(): bool | |
| 519 | + { | |
| 520 | + return $this->showRatingText; | |
| 521 | + } | |
| 522 | + | |
| 523 | + /** | |
| 524 | + * Set showRatingText flag. | |
| 525 | + * | |
| 526 | + * @param bool|null $val | |
| 527 | + */ | |
| 528 | + public function setShowRatingText(?bool $val): void | |
| 529 | + { | |
| 530 | + $this->showRatingText = (bool)$val; | |
| 531 | + } | |
| 532 | + | |
| 533 | + /** | |
| 534 | + * Get the agreement text. | |
| 535 | + * @return string | |
| 536 | + */ | |
| 537 | + public function getAgreementText(): string | |
| 538 | + { | |
| 539 | + return $this->agreementText; | |
| 540 | + } | |
| 541 | + | |
| 542 | + /** | |
| 543 | + * Set the agreement text. | |
| 544 | + * | |
| 545 | + * @param string $agreementText | |
| 546 | + */ | |
| 547 | + public function setAgreementText(string $agreementText): void | |
| 548 | + { | |
| 549 | + $this->agreementText = $agreementText; | |
| 550 | + } | |
| 551 | + | |
| 552 | + /** | |
| 553 | + * Get limitRange. | |
| 554 | + * @return bool | |
| 555 | + */ | |
| 556 | + public function isLimitRange(): bool | |
| 557 | + { | |
| 558 | + return $this->limitRange; | |
| 559 | + } | |
| 560 | + | |
| 561 | + /** | |
| 562 | + * Set limitRange. | |
| 563 | + * @param bool $limitRange | |
| 564 | + */ | |
| 565 | + public function setLimitRange(bool $limitRange): void | |
| 566 | + { | |
| 567 | + $this->limitRange = $limitRange; | |
| 568 | + } | |
| 569 | + | |
| 570 | + /** | |
| 411 | 571 | * @return array<string, mixed> |
| 412 | 572 | */ |
| 413 | 573 | public function toArray(): array |
| 414 | 574 | { |
| @@ -429,11 +589,18 @@ | ||
| 429 | 589 | 'phoneAutoDetect' => $this->isPhoneAutoDetect(), |
| 430 | 590 | 'minValue' => $this->getMinValue(), |
| 431 | 591 | 'maxValue' => $this->getMaxValue(), |
| 432 | 592 | 'step' => $this->getStep(), |
| 593 | + 'showGrid' => $this->getShowGrid(), | |
| 433 | 594 | 'numberFormat' => $this->getNumberFormat(), |
| 434 | 595 | 'visible' => $this->isVisible(), |
| 596 | + 'showRatingText' => $this->isShowRatingText(), | |
| 597 | + 'htmlContent' => $this->getHtmlContent(), | |
| 598 | + 'agreementText' => $this->getAgreementText(), | |
| 599 | + 'limitRange' => $this->isLimitRange(), | |
| 435 | 600 | ], |
| 436 | - $this->timeSettings->toArray() | |
| 601 | + $this->confirmationSettings->toArray(), | |
| 602 | + $this->timeSettings->toArray(), | |
| 603 | + $this->dateSettings->toArray() | |
| 437 | 604 | ); |
| 438 | 605 | } |
| 439 | 606 | } |