'email', 'reply_to_address' => 'email', 'email_count' => 'int', 'sms_count' => 'int', 'apikey' => 'string' ]; } public function get_site_template_name() : string { return 'config_panel'; } private function validate_result() : ?string { if (!$this->is_validated('source_address')) { return 'Source E-Mail address is not valid.'; } if (!$this->is_validated('reply_to_address')) { return 'Reply to E-Mail address it not valid.'; } if (!$this->is_validated('email_count')) { return 'Count of the E-Mails is not valid.'; } if (!$this->is_validated('sms_count')) { return 'Count of the SMS-es is not valid.'; } if (!$this->is_validated('apikey')) { return 'Api Key is not valid.'; } if (strlen($this->get_validated('apikey')) < 16) { return 'Api Key must has minimum 16 characters.'; } return null; } private function save() { $validate = $this->validate_result(); if ($validate !== null) { $this->error_toast($validate); return; } $settings = $this->get_settings(); $settings ->save('source_address', $this->get_validated('source_address')) ->save('reply_to_address', $this->get_validated('reply_to_address')) ->save('email_count', $this->get_validated('email_count')) ->save('sms_count', $this->get_validated('sms_count')) ->save('apikey', $this->get_validated('apikey')); $this->success_toast('Settings had been saved.'); } public function process() : self { if ($this->is_received('save')) { $this->save(); } $this->set('source_address', $this->get_settings()->get('source_address')); $this->set('reply_to_address', $this->get_settings()->get('reply_to_address')); $this->set('email_count', $this->get_settings()->get('email_count')); $this->set('sms_count', $this->get_settings()->get('sms_count')); $this->set('apikey', $this->get_settings()->get('apikey')); return $this; } }