| 1 |
<?php |
| 2 |
/** |
| 3 |
* Form Validated Event |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Events\Form |
| 6 |
* @since 4.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Forge12\DoubleOptIn\Events\Form; |
| 10 |
|
| 11 |
use Forge12\DoubleOptIn\EventSystem\Event; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Class FormValidatedEvent |
| 19 |
* |
| 20 |
* Dispatched when form validation is complete. |
| 21 |
*/ |
| 22 |
class FormValidatedEvent extends Event { |
| 23 |
|
| 24 |
private int $formId; |
| 25 |
private string $formType; |
| 26 |
private bool $isValid; |
| 27 |
private array $errors; |
| 28 |
private string $recipientEmail; |
| 29 |
|
| 30 |
/** |
| 31 |
* Constructor. |
| 32 |
* |
| 33 |
* @param int $formId The form ID. |
| 34 |
* @param string $formType The form type. |
| 35 |
* @param bool $isValid Whether validation passed. |
| 36 |
* @param string $recipientEmail The extracted recipient email. |
| 37 |
* @param array $errors Validation errors if any. |
| 38 |
*/ |
| 39 |
public function __construct( |
| 40 |
int $formId, |
| 41 |
string $formType, |
| 42 |
bool $isValid, |
| 43 |
string $recipientEmail, |
| 44 |
array $errors = array() |
| 45 |
) { |
| 46 |
parent::__construct(); |
| 47 |
$this->formId = $formId; |
| 48 |
$this->formType = $formType; |
| 49 |
$this->isValid = $isValid; |
| 50 |
$this->recipientEmail = $recipientEmail; |
| 51 |
$this->errors = $errors; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* {@inheritdoc} |
| 56 |
*/ |
| 57 |
public static function getWordPressHookName(): string { |
| 58 |
return 'f12_cf7_doubleoptin_form_validated'; |
| 59 |
} |
| 60 |
|
| 61 |
public function getFormId(): int { |
| 62 |
return $this->formId; |
| 63 |
} |
| 64 |
|
| 65 |
public function getFormType(): string { |
| 66 |
return $this->formType; |
| 67 |
} |
| 68 |
|
| 69 |
public function isValid(): bool { |
| 70 |
return $this->isValid; |
| 71 |
} |
| 72 |
|
| 73 |
public function getRecipientEmail(): string { |
| 74 |
return $this->recipientEmail; |
| 75 |
} |
| 76 |
|
| 77 |
public function getErrors(): array { |
| 78 |
return $this->errors; |
| 79 |
} |
| 80 |
} |
| 81 |
|