|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Leonidas\Library\Admin\Component\SettingsField; |
|
4
|
|
|
|
|
5
|
|
|
use Leonidas\Contracts\Admin\Component\SettingsFieldBuilderInterface; |
|
6
|
|
|
use Leonidas\Contracts\Admin\Component\SettingsFieldInterface; |
|
7
|
|
|
use Leonidas\Library\Admin\Component\SettingsField\Traits\HasSettingsFieldDataTrait; |
|
8
|
|
|
use WebTheory\HttpPolicy\ServerRequestPolicyInterface; |
|
9
|
|
|
use WebTheory\Saveyour\Contracts\Field\FormFieldInterface; |
|
10
|
|
|
use WebTheory\Saveyour\Contracts\Formatting\InputFormatterInterface; |
|
11
|
|
|
|
|
12
|
|
|
class SettingsFieldBuilder implements SettingsFieldBuilderInterface |
|
13
|
|
|
{ |
|
14
|
|
|
use HasSettingsFieldDataTrait; |
|
15
|
|
|
|
|
16
|
|
|
public function __construct(string $id) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->id = $id; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function setting(string $setting) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->setting = $setting; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function id(string $id) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->id = $id; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function title(string $title) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->title = $title; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function page(string $page) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->page = $page; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function section(string $section) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->section = $section; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function inputId(string $inputId) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->inputId = $inputId; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function args(array $args) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->args = $args; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function formatter(InputFormatterInterface $formatter) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->formatter = $formatter; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function input(FormFieldInterface $input) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->input = $input; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function policy(ServerRequestPolicyInterface $policy) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->policy = $policy; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getPolicy(): ?ServerRequestPolicyInterface |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->policy; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function get(): SettingsFieldInterface |
|
77
|
|
|
{ |
|
78
|
|
|
return new SettingsField( |
|
79
|
|
|
$this->getSetting(), |
|
80
|
|
|
$this->getId(), |
|
81
|
|
|
$this->getTitle(), |
|
82
|
|
|
$this->getPage(), |
|
83
|
|
|
$this->getSection(), |
|
84
|
|
|
$this->getInputId(), |
|
85
|
|
|
$this->getArgs(), |
|
86
|
|
|
$this->getInput(), |
|
87
|
|
|
$this->getFormatter(), |
|
88
|
|
|
$this->getPolicy() |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|