<?php
|
namespace JVBase\registrar\config;
|
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
|
final class Register extends Config {
|
public string $title;
|
public string $description;
|
public array $fields = [
|
'username' => [
|
'type' => 'email',
|
'label' => 'Your Email',
|
'required' => true,
|
],
|
'password' => [
|
'type' => 'text',
|
'subtype' => 'password',
|
'label' => 'Your Password',
|
],
|
'password_check' => [
|
'type' => 'text',
|
'subtype' => 'password',
|
'label' => 'Verify Password',
|
],
|
];
|
|
public function __construct() {
|
}
|
|
public function setTitle(string $title): self {
|
$this->title = $title;
|
return $this;
|
}
|
public function getTitle():string
|
{
|
return $this->title;
|
}
|
|
public function setDescription(string|array $desc):self
|
{
|
if (is_array($desc)) {
|
$desc = implode('', array_map(function ($p) { return '<p>'.$p.'</p>';}, $desc));
|
} else if (!str_contains('<p>', $desc)) {
|
$desc = '<p>'.$desc.'</p>';
|
}
|
$this->description = $desc;
|
return $this;
|
}
|
public function getDescription():string|array
|
{
|
return $this->description;
|
}
|
|
public function setFields(array $fields):self
|
{
|
$this->fields = array_merge($this->fields, $fields);
|
return $this;
|
}
|
|
public function getFields():array
|
{
|
return $this->fields;
|
}
|
|
function getConfig(): array
|
{
|
return [
|
'title' => $this->title ?? false,
|
'description' => $this->description??false,
|
'fields' => $this->fields
|
];
|
}
|
}
|